Skip to content

Commit

Permalink
Added more functions to abstract Test class and arrows popping up at …
Browse files Browse the repository at this point in the history
…slightly randomized intervals and response to arrow press on keyboard
  • Loading branch information
MiaKL committed Oct 16, 2024
1 parent e67ead8 commit 95afe0f
Show file tree
Hide file tree
Showing 8 changed files with 411 additions and 29 deletions.
41 changes: 41 additions & 0 deletions Assets/Non-VR Rig_Action Maps/PlayerInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public @PlayerInput()
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Arrows"",
""type"": ""PassThrough"",
""id"": ""358655aa-723d-4b90-a8a3-c1badd8319a1"",
""expectedControlType"": ""Key"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
Expand Down Expand Up @@ -113,6 +122,28 @@ public @PlayerInput()
""action"": ""Look"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""239c25d4-72f2-4e2a-9c83-0becced67f4f"",
""path"": ""<Keyboard>/leftArrow"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Arrows"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""1f0a9fcd-54a6-468a-8f71-375c47a2e5bf"",
""path"": ""<Keyboard>/rightArrow"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Arrows"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
Expand All @@ -123,6 +154,7 @@ public @PlayerInput()
m_Player = asset.FindActionMap("Player", throwIfNotFound: true);
m_Player_Movement = m_Player.FindAction("Movement", throwIfNotFound: true);
m_Player_Look = m_Player.FindAction("Look", throwIfNotFound: true);
m_Player_Arrows = m_Player.FindAction("Arrows", throwIfNotFound: true);
}

~@PlayerInput()
Expand Down Expand Up @@ -191,12 +223,14 @@ public int FindBinding(InputBinding bindingMask, out InputAction action)
private List<IPlayerActions> m_PlayerActionsCallbackInterfaces = new List<IPlayerActions>();
private readonly InputAction m_Player_Movement;
private readonly InputAction m_Player_Look;
private readonly InputAction m_Player_Arrows;
public struct PlayerActions
{
private @PlayerInput m_Wrapper;
public PlayerActions(@PlayerInput wrapper) { m_Wrapper = wrapper; }
public InputAction @Movement => m_Wrapper.m_Player_Movement;
public InputAction @Look => m_Wrapper.m_Player_Look;
public InputAction @Arrows => m_Wrapper.m_Player_Arrows;
public InputActionMap Get() { return m_Wrapper.m_Player; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
Expand All @@ -212,6 +246,9 @@ public void AddCallbacks(IPlayerActions instance)
@Look.started += instance.OnLook;
@Look.performed += instance.OnLook;
@Look.canceled += instance.OnLook;
@Arrows.started += instance.OnArrows;
@Arrows.performed += instance.OnArrows;
@Arrows.canceled += instance.OnArrows;
}

private void UnregisterCallbacks(IPlayerActions instance)
Expand All @@ -222,6 +259,9 @@ private void UnregisterCallbacks(IPlayerActions instance)
@Look.started -= instance.OnLook;
@Look.performed -= instance.OnLook;
@Look.canceled -= instance.OnLook;
@Arrows.started -= instance.OnArrows;
@Arrows.performed -= instance.OnArrows;
@Arrows.canceled -= instance.OnArrows;
}

public void RemoveCallbacks(IPlayerActions instance)
Expand All @@ -243,5 +283,6 @@ public interface IPlayerActions
{
void OnMovement(InputAction.CallbackContext context);
void OnLook(InputAction.CallbackContext context);
void OnArrows(InputAction.CallbackContext context);
}
}
31 changes: 31 additions & 0 deletions Assets/Non-VR Rig_Action Maps/PlayerInput.inputactions
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Arrows",
"type": "PassThrough",
"id": "358655aa-723d-4b90-a8a3-c1badd8319a1",
"expectedControlType": "Key",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
Expand Down Expand Up @@ -90,6 +99,28 @@
"action": "Look",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "239c25d4-72f2-4e2a-9c83-0becced67f4f",
"path": "<Keyboard>/leftArrow",
"interactions": "",
"processors": "",
"groups": "",
"action": "Arrows",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "1f0a9fcd-54a6-468a-8f71-375c47a2e5bf",
"path": "<Keyboard>/rightArrow",
"interactions": "",
"processors": "",
"groups": "",
"action": "Arrows",
"isComposite": false,
"isPartOfComposite": false
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Prefabs/Arrow.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ MonoBehaviour:
m_PreserveMeshAssetOnDestroy: 0
assetGuid:
m_Mesh: {fileID: 0}
m_VersionIndex: 416
m_VersionIndex: 419
m_IsSelectable: 1
m_SelectedFaces:
m_SelectedEdges: []
Expand Down
91 changes: 76 additions & 15 deletions Assets/Scenes/BasicScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ GameObject:
- component: {fileID: 33726348}
- component: {fileID: 33726349}
m_Layer: 0
m_Name: TestStart_TimedTest(Demo)
m_Name: TestStart_ReactionTest
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -1333,7 +1333,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4392ffc77a506104d80256dc28470f19, type: 3}
m_Name:
m_EditorClassIdentifier:
test: {fileID: 133065661}
test: {fileID: 370492606}
colorChangeSpeed: 0.5
endColor: {r: 0, g: 0, b: 0, a: 0}
--- !u!95 &33726348
Expand Down Expand Up @@ -1861,6 +1861,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 133065660}
- {fileID: 370492605}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &294338759
Expand Down Expand Up @@ -2522,6 +2523,54 @@ MonoBehaviour:
m_LightCookieSize: {x: 1, y: 1}
m_LightCookieOffset: {x: 0, y: 0}
m_SoftShadowQuality: 0
--- !u!1 &370492604
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 370492605}
- component: {fileID: 370492606}
m_Layer: 0
m_Name: ReactionTest
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &370492605
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 370492604}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.6790538, y: 1.4781137, z: -0.49147892}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 992329722}
- {fileID: 1145431398}
m_Father: {fileID: 273083091}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &370492606
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 370492604}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 06139d0a49ec7124a9143ceeabf246c0, type: 3}
m_Name:
m_EditorClassIdentifier:
leftArrow: {fileID: 992329716}
rightArrow: {fileID: 1145431392}
--- !u!850595691 &404504638
LightingSettings:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2940,7 +2989,7 @@ GameObject:
m_Component:
- component: {fileID: 749134439}
m_Layer: 0
m_Name: TestStartContainer_TimedTest(Demo)
m_Name: TestStartContainer_ReactionTest
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -6686,12 +6735,12 @@ GameObject:
- component: {fileID: 992329718}
- component: {fileID: 992329717}
m_Layer: 0
m_Name: Arrow
m_Name: LeftArrow
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!64 &992329717
MeshCollider:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -7163,11 +7212,11 @@ Transform:
m_GameObject: {fileID: 992329716}
serializedVersion: 2
m_LocalRotation: {x: -0.000002078712, y: -0.70710796, z: -0.7071057, w: 0.0000021234155}
m_LocalPosition: {x: -2.000001, y: 0.8749997, z: 1.1249979}
m_LocalPosition: {x: -0.5127349, y: -0.63475317, z: 2.0005155}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_Father: {fileID: 370492605}
m_LocalEulerAnglesHint: {x: -90, y: 0, z: -180}
--- !u!1 &1045422745
GameObject:
Expand Down Expand Up @@ -7715,6 +7764,16 @@ Transform:
- {fileID: 1045422747}
m_Father: {fileID: 294338760}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1145431392 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8971293823169540501, guid: 05ac1c067e4dc2f41bd4a084a23e56e9, type: 3}
m_PrefabInstance: {fileID: 1220186818431017113}
m_PrefabAsset: {fileID: 0}
--- !u!4 &1145431398 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2769561743914269895, guid: 05ac1c067e4dc2f41bd4a084a23e56e9, type: 3}
m_PrefabInstance: {fileID: 1220186818431017113}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1179475551
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -11900,7 +11959,7 @@ PrefabInstance:
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_TransformParent: {fileID: 370492605}
m_Modifications:
- target: {fileID: 417905327810629334, guid: 05ac1c067e4dc2f41bd4a084a23e56e9, type: 3}
propertyPath: m_Mesh
Expand All @@ -11912,19 +11971,19 @@ PrefabInstance:
objectReference: {fileID: 211118913}
- target: {fileID: 467136503058936559, guid: 05ac1c067e4dc2f41bd4a084a23e56e9, type: 3}
propertyPath: m_VersionIndex
value: 419
value: 422
objectReference: {fileID: 0}
- target: {fileID: 2769561743914269895, guid: 05ac1c067e4dc2f41bd4a084a23e56e9, type: 3}
propertyPath: m_LocalPosition.x
value: -1
value: 0.48726606
objectReference: {fileID: 0}
- target: {fileID: 2769561743914269895, guid: 05ac1c067e4dc2f41bd4a084a23e56e9, type: 3}
propertyPath: m_LocalPosition.y
value: 0.8749997
value: -0.63475317
objectReference: {fileID: 0}
- target: {fileID: 2769561743914269895, guid: 05ac1c067e4dc2f41bd4a084a23e56e9, type: 3}
propertyPath: m_LocalPosition.z
value: 1.375
value: 2.2505174
objectReference: {fileID: 0}
- target: {fileID: 2769561743914269895, guid: 05ac1c067e4dc2f41bd4a084a23e56e9, type: 3}
propertyPath: m_LocalRotation.w
Expand Down Expand Up @@ -11960,7 +12019,11 @@ PrefabInstance:
objectReference: {fileID: 211118913}
- target: {fileID: 8971293823169540501, guid: 05ac1c067e4dc2f41bd4a084a23e56e9, type: 3}
propertyPath: m_Name
value: Arrow
value: RightArrow
objectReference: {fileID: 0}
- target: {fileID: 8971293823169540501, guid: 05ac1c067e4dc2f41bd4a084a23e56e9, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
Expand All @@ -11980,5 +12043,3 @@ SceneRoots:
- {fileID: 1108897244}
- {fileID: 1950691295}
- {fileID: 273083091}
- {fileID: 992329722}
- {fileID: 1220186818431017113}
Loading

0 comments on commit 95afe0f

Please sign in to comment.