移除ECM2
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8ae32dc088988e4a8c1bc3aa94e1980
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b54570a11beb04408cb0b800a30e3d4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,103 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace ECM2.Walkthrough.Ex23
|
||||
{
|
||||
/// <summary>
|
||||
/// This example shows how to make use of the new Input System,
|
||||
/// in particular, the PlayerInput component to control a Character.
|
||||
///
|
||||
/// These handlers are updated and managed by the PlayerInput component.
|
||||
/// </summary>
|
||||
|
||||
public class CharacterInput : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Our controlled character.
|
||||
/// </summary>
|
||||
|
||||
[Tooltip("Character to be controlled.\n" +
|
||||
"If not assigned, this will look into this GameObject.")]
|
||||
[SerializeField]
|
||||
private Character _character;
|
||||
|
||||
/// <summary>
|
||||
/// Current movement input values.
|
||||
/// </summary>
|
||||
|
||||
private Vector2 _movementInput;
|
||||
|
||||
/// <summary>
|
||||
/// Movement InputAction event handler.
|
||||
/// </summary>
|
||||
|
||||
public void OnMove(InputAction.CallbackContext context)
|
||||
{
|
||||
_movementInput = context.ReadValue<Vector2>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Jump InputAction event handler.
|
||||
/// </summary>
|
||||
|
||||
public void OnJump(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.started)
|
||||
_character.Jump();
|
||||
else if (context.canceled)
|
||||
_character.StopJumping();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Crouch InputAction event handler.
|
||||
/// </summary>
|
||||
|
||||
public void OnCrouch(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.started)
|
||||
_character.Crouch();
|
||||
else if (context.canceled)
|
||||
_character.UnCrouch();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle polled input here (ie: movement, look, etc.)
|
||||
/// </summary>
|
||||
|
||||
protected virtual void HandleInput()
|
||||
{
|
||||
// Compose a movement direction vector in world space
|
||||
|
||||
Vector3 movementDirection = Vector3.zero;
|
||||
|
||||
movementDirection += Vector3.forward * _movementInput.y;
|
||||
movementDirection += Vector3.right * _movementInput.x;
|
||||
|
||||
// If character has a camera assigned,
|
||||
// make movement direction relative to this camera view direction
|
||||
|
||||
if (_character.cameraTransform)
|
||||
{
|
||||
movementDirection
|
||||
= movementDirection.relativeTo(_character.cameraTransform, _character.GetUpVector());
|
||||
}
|
||||
|
||||
// Set character's movement direction vector
|
||||
|
||||
_character.SetMovementDirection(movementDirection);
|
||||
}
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
// If character not assigned, attempts to cache from this current GameObject
|
||||
|
||||
if (_character == null)
|
||||
_character = GetComponent<Character>();
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
HandleInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 855c880aafd786e469e74d8dcc0f4fc8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user