浏览代码

Improvement: Switched Warrior PlayerInput from SendMessage to UnityEvents

/V2
andytouch 4 年前
当前提交
0a654ac7
共有 3 个文件被更改,包括 340 次插入15 次删除
  1. 93
      InputSystem_Warriors_Project/Assets/Prefabs/Warrior/Player_Warrior.prefab
  2. 244
      InputSystem_Warriors_Project/Assets/Scenes/Scene_Example_Warriors.unity
  3. 18
      InputSystem_Warriors_Project/Assets/Scripts/Behaviours/Player/PlayerController.cs

93
InputSystem_Warriors_Project/Assets/Prefabs/Warrior/Player_Warrior.prefab


m_EditorClassIdentifier:
m_Actions: {fileID: -944628639613478452, guid: aa45cad44afd790488f6540bc766db91,
type: 3}
m_NotificationBehavior: 0
m_NotificationBehavior: 2
m_Calls: []
m_Calls:
- m_Target: {fileID: 1743518200311987065}
m_MethodName: OnDeviceLost
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_Calls: []
m_Calls:
- m_Target: {fileID: 1743518200311987065}
m_MethodName: OnDeviceRegained
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_Calls: []
m_Calls:
- m_Target: {fileID: 1743518200311987065}
m_MethodName: OnControlsChanged
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_Calls: []
m_Calls:
- m_Target: {fileID: 1743518200311987065}
m_MethodName: OnMovement
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_ActionId: 548e32fd-77d1-40e5-8197-32ca56b41bc0
m_ActionName: Player Controls/Movement[/Keyboard/w,/Keyboard/s,/Keyboard/a,/Keyboard/d,/DualShock4GamepadHID/leftStick,/XInputControllerWindows/leftStick]
- m_PersistentCalls:

- m_PersistentCalls:
m_Calls: []
m_Calls:
- m_Target: {fileID: 1743518200311987065}
m_MethodName: OnAttack
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_Calls: []
m_Calls:
- m_Target: {fileID: 1743518200311987065}
m_MethodName: OnTogglePause
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_Calls: []
m_Calls:
- m_Target: {fileID: 1743518200311987065}
m_MethodName: OnTogglePause
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_ActionId: e773b1f9-ce5b-4fa2-9c1f-d194202c43b7
m_ActionName: Menu Controls/TogglePause[/Keyboard/p,/DualShock4GamepadHID/start,/XInputControllerWindows/start]
- m_PersistentCalls:

244
InputSystem_Warriors_Project/Assets/Scenes/Scene_Example_Warriors.unity


type: 3}
m_PrefabInstance: {fileID: 280609174585779900}
m_PrefabAsset: {fileID: 0}
--- !u!114 &16277602 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 1743518200311987065, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
m_PrefabInstance: {fileID: 280609174585779900}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 16277595}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e20fb9a3b0e7eae4e9e630fc6e8b1a3f, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &31590763
GameObject:
m_ObjectHideFlags: 3

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1833978498}
m_LocalRotation: {x: 0.16914704, y: -0.0021507803, z: 0.00036911768, w: 0.98558843}
m_LocalRotation: {x: 0.16914704, y: -0.002150739, z: 0.0003691106, w: 0.98558843}
m_LocalPosition: {x: 0.01616344, y: -4.7452283, z: -3.7034783}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:

objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[1].m_PersistentCalls.m_Calls.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[4].m_PersistentCalls.m_Calls.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ControlsChangedEvent.m_PersistentCalls.m_Calls.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceRegainedEvent.m_PersistentCalls.m_Calls.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceLostEvent.m_PersistentCalls.m_Calls.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_NotificationBehavior
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[1].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[1].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[4].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[4].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ControlsChangedEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ControlsChangedEvent.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceRegainedEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceRegainedEvent.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceLostEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceLostEvent.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 16277602}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnMovement
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 16277602}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnAttack
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 16277602}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnTogglePause
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[4].m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 16277602}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[4].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnTogglePause
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ActionEvents.Array.data[4].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceLostEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 16277602}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceLostEvent.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnDeviceLost
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceLostEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceRegainedEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 16277602}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceRegainedEvent.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnDeviceRegained
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_DeviceRegainedEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ControlsChangedEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 16277602}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ControlsChangedEvent.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnControlsChanged
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987064, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}
propertyPath: m_ControlsChangedEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 1743518200311987069, guid: ca9ee4e0ea2b85646be0b08bab27e559,
type: 3}

18
InputSystem_Warriors_Project/Assets/Scripts/Behaviours/Player/PlayerController.cs


//It stores the input Vector as a Vector3 to then be used by the smoothing function.
private void OnMovement(InputValue value)
public void OnMovement(InputAction.CallbackContext value)
Vector2 inputMovement = value.Get<Vector2>();
Vector2 inputMovement = value.ReadValue<Vector2>();
private void OnAttack(InputValue value)
public void OnAttack(InputAction.CallbackContext value)
playerAnimationBehaviour.PlayAttackAnimation();
if(value.started)
{
playerAnimationBehaviour.PlayAttackAnimation();
}
private void OnTogglePause(InputValue value)
public void OnTogglePause(InputAction.CallbackContext value)
GameManager.Instance.TogglePauseState(this);
if(value.started)
{
GameManager.Instance.TogglePauseState(this);
}
}

正在加载...
取消
保存