导入资源
This commit is contained in:
9
Assets/Samples/Crest/5.4.2/Boats/Scripts/Assembly.cs
Normal file
9
Assets/Samples/Crest/5.4.2/Boats/Scripts/Assembly.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("WaveHarmonic.Crest.Samples.Submarine")]
|
||||
|
||||
// Define empty namespaces for when assemblies are not present.
|
||||
namespace UnityEngine.InputSystem { }
|
||||
11
Assets/Samples/Crest/5.4.2/Boats/Scripts/Assembly.cs.meta
Normal file
11
Assets/Samples/Crest/5.4.2/Boats/Scripts/Assembly.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31c79f361b2bd40af9a7d52025a8c0f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
121
Assets/Samples/Crest/5.4.2/Boats/Scripts/PlayerControl.cs
Normal file
121
Assets/Samples/Crest/5.4.2/Boats/Scripts/PlayerControl.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#if d_Unity_InputSystem && ENABLE_INPUT_SYSTEM
|
||||
#define d_InputSystem
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
#pragma warning disable CS0414
|
||||
|
||||
namespace WaveHarmonic.Crest.Watercraft.Examples
|
||||
{
|
||||
sealed class PlayerControl : Control
|
||||
{
|
||||
[SerializeField, HideInInspector]
|
||||
int _Version = 0;
|
||||
|
||||
#if d_InputSystem
|
||||
[SerializeField]
|
||||
Key _DriveForward = Key.W;
|
||||
|
||||
[SerializeField]
|
||||
Key _DriveBackward = Key.S;
|
||||
|
||||
[SerializeField]
|
||||
Key _SteerLeftward = Key.A;
|
||||
|
||||
[SerializeField]
|
||||
Key _SteerRightward = Key.D;
|
||||
|
||||
[SerializeField]
|
||||
Key _FloatUpward = Key.E;
|
||||
|
||||
[SerializeField]
|
||||
Key _FloatDownward = Key.Q;
|
||||
#else
|
||||
[SerializeField]
|
||||
int _DriveForward;
|
||||
|
||||
[SerializeField]
|
||||
int _DriveBackward;
|
||||
|
||||
[SerializeField]
|
||||
int _SteerLeftward;
|
||||
|
||||
[SerializeField]
|
||||
int _SteerRightward;
|
||||
|
||||
[SerializeField]
|
||||
int _FloatUpward;
|
||||
|
||||
[SerializeField]
|
||||
int _FloatDownward;
|
||||
#endif
|
||||
|
||||
#if d_InputSystem
|
||||
[HideInInspector]
|
||||
#endif
|
||||
[Tooltip("The input axis name for throttle. See Project Settings > Input Manager.")]
|
||||
[SerializeField]
|
||||
string _DriveInputAxis = "Vertical";
|
||||
|
||||
#if d_InputSystem
|
||||
[HideInInspector]
|
||||
#endif
|
||||
[Tooltip("The input axis name for steering. See Project Settings > Input Manager.")]
|
||||
[SerializeField]
|
||||
string _SteerInputAxis = "Horizontal";
|
||||
|
||||
#if d_InputSystem
|
||||
[HideInInspector]
|
||||
#endif
|
||||
[SerializeField]
|
||||
KeyCode _FloatUpwards = KeyCode.E;
|
||||
|
||||
#if d_InputSystem
|
||||
[HideInInspector]
|
||||
#endif
|
||||
[SerializeField]
|
||||
KeyCode _FloatDownwards = KeyCode.Q;
|
||||
|
||||
[Tooltip("Whether to allow submerge control.")]
|
||||
[SerializeField]
|
||||
bool _Submersible;
|
||||
|
||||
#pragma warning disable UNT0001
|
||||
// Here to force the checkbox to show.
|
||||
void Start() { }
|
||||
#pragma warning restore UNT0001
|
||||
|
||||
public override Vector3 Input
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!isActiveAndEnabled || !Application.isFocused) return Vector3.zero;
|
||||
|
||||
var input = Vector3.zero;
|
||||
#if d_InputSystem
|
||||
input.z += Keyboard.current[_DriveForward].isPressed ? 1f : 0f;
|
||||
input.z += Keyboard.current[_DriveBackward].isPressed ? -1f : 0f;
|
||||
input.x += Keyboard.current[_SteerLeftward].isPressed ? -1f : 0f;
|
||||
input.x += Keyboard.current[_SteerRightward].isPressed ? 1f : 0f;
|
||||
input.y += Keyboard.current[_FloatUpward].isPressed ? 1f : 0f;
|
||||
input.y += Keyboard.current[_FloatDownward].isPressed ? -1f : 0f;
|
||||
#else
|
||||
input.z = UnityEngine.Input.GetAxis(_DriveInputAxis);
|
||||
input.x = UnityEngine.Input.GetAxis(_SteerInputAxis);
|
||||
input.y += UnityEngine.Input.GetKey(_FloatUpwards) ? 1f : 0f;
|
||||
input.y += UnityEngine.Input.GetKey(_FloatDownwards) ? -1f : 0f;
|
||||
#endif
|
||||
|
||||
// Steering towards same direction as forward when going backwards.
|
||||
if (input.z < 0f) input.x *= -1f;
|
||||
if (!_Submersible) input.y = 0f;
|
||||
return input;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00270ad31891444bcb3fa64c9df57571
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "WaveHarmonic.Crest.Samples.Boats",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c",
|
||||
"GUID:7c347618730f5467f86a58f333ce21df"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [
|
||||
"UNITY_2022_3_OR_NEWER",
|
||||
"d_Crest"
|
||||
],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.unity.inputsystem",
|
||||
"expression": "",
|
||||
"define": "d_Unity_InputSystem"
|
||||
},
|
||||
{
|
||||
"name": "com.waveharmonic.crest",
|
||||
"expression": "",
|
||||
"define": "d_Crest"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b764708e9f9f5422cb50bbec2bdf0c0e
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user