From 02dc79ee00685f4877e604d042db879f6cdf32fc Mon Sep 17 00:00:00 2001 From: oogushiyuuga Date: Wed, 13 May 2026 16:33:07 +0900 Subject: [PATCH] =?UTF-8?q?Test=E8=BF=BD=E5=8A=A0=E3=83=91=E3=83=83?= =?UTF-8?q?=E3=82=AFVol.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Input.meta | 8 + Assets/Input/New Actions.inputactions | 95 +++++++++++ Assets/Input/New Actions.inputactions.meta | 14 ++ Assets/InputLR.prefab | 46 ++++++ Assets/InputLR.prefab.meta | 7 + Assets/InputManagerLR.prefab | 47 ++++++ Assets/InputManagerLR.prefab.meta | 7 + Assets/Scenes/Test.unity | 177 ++++++++++++++++++++- Assets/Scripts/InputLR.cs | 28 ++++ Assets/Scripts/InputLR.cs.meta | 2 + Assets/Scripts/InputManagerLR.cs | 57 +++++++ Assets/Scripts/InputManagerLR.cs.meta | 2 + Assets/Scripts/ItemCountDown.cs | 62 ++++++++ Assets/Scripts/ItemCountDown.cs.meta | 2 + 14 files changed, 546 insertions(+), 8 deletions(-) create mode 100644 Assets/Input.meta create mode 100644 Assets/Input/New Actions.inputactions create mode 100644 Assets/Input/New Actions.inputactions.meta create mode 100644 Assets/InputLR.prefab create mode 100644 Assets/InputLR.prefab.meta create mode 100644 Assets/InputManagerLR.prefab create mode 100644 Assets/InputManagerLR.prefab.meta create mode 100644 Assets/Scripts/InputLR.cs create mode 100644 Assets/Scripts/InputLR.cs.meta create mode 100644 Assets/Scripts/InputManagerLR.cs create mode 100644 Assets/Scripts/InputManagerLR.cs.meta create mode 100644 Assets/Scripts/ItemCountDown.cs create mode 100644 Assets/Scripts/ItemCountDown.cs.meta diff --git a/Assets/Input.meta b/Assets/Input.meta new file mode 100644 index 0000000..24571ff --- /dev/null +++ b/Assets/Input.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 893e69241fa934ef2bdbcc8d56657f16 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Input/New Actions.inputactions b/Assets/Input/New Actions.inputactions new file mode 100644 index 0000000..367cfce --- /dev/null +++ b/Assets/Input/New Actions.inputactions @@ -0,0 +1,95 @@ +{ + "version": 1, + "name": "New Actions", + "maps": [ + { + "name": "Test", + "id": "b2843e79-b1b2-454c-9939-148d9b84f906", + "actions": [ + { + "name": "XR_PrimaryButtonR", + "type": "Button", + "id": "ada6f454-e92d-4eca-81ed-495aa3fc1c0c", + "expectedControlType": "", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "XR_SecondaryButtonR", + "type": "Button", + "id": "4f4e3cc0-4018-4dac-9af0-fb5977a04179", + "expectedControlType": "", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "XR_PrimaryButtonL", + "type": "Button", + "id": "11d92c87-4a30-4af5-98a2-6dc5f17733dd", + "expectedControlType": "", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "XR_SecondaryButtonL", + "type": "Button", + "id": "4695b210-5a41-434a-82c5-00facc76a6dd", + "expectedControlType": "", + "processors": "", + "interactions": "", + "initialStateCheck": false + } + ], + "bindings": [ + { + "name": "", + "id": "2ae0e108-71a2-42bc-9547-24b5a1c1308a", + "path": "{RightHand}/{PrimaryButton}", + "interactions": "", + "processors": "", + "groups": "", + "action": "XR_PrimaryButtonR", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "f89ebeda-d413-4430-bb0b-914fa3fa5ebf", + "path": "{RightHand}/{SecondaryButton}", + "interactions": "", + "processors": "", + "groups": "", + "action": "XR_SecondaryButtonR", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "f7f5e97e-7aca-4f09-b5d9-2c6d2298a3af", + "path": "{LeftHand}/{PrimaryButton}", + "interactions": "", + "processors": "", + "groups": "", + "action": "XR_PrimaryButtonL", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "82995bf8-b451-4d5b-beb8-c0212b83f3e7", + "path": "{LeftHand}/{SecondaryButton}", + "interactions": "", + "processors": "", + "groups": "", + "action": "XR_SecondaryButtonL", + "isComposite": false, + "isPartOfComposite": false + } + ] + } + ], + "controlSchemes": [] +} \ No newline at end of file diff --git a/Assets/Input/New Actions.inputactions.meta b/Assets/Input/New Actions.inputactions.meta new file mode 100644 index 0000000..e972205 --- /dev/null +++ b/Assets/Input/New Actions.inputactions.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 5bbfa95a7ff8c42848c1cb2a29323d66 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3} + generateWrapperCode: 0 + wrapperCodePath: + wrapperClassName: + wrapperCodeNamespace: diff --git a/Assets/InputLR.prefab b/Assets/InputLR.prefab new file mode 100644 index 0000000..55f2377 --- /dev/null +++ b/Assets/InputLR.prefab @@ -0,0 +1,46 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &4922478499971886893 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3464648787695271206} + - component: {fileID: 235776220098759035} + m_Layer: 0 + m_Name: InputLR + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3464648787695271206 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4922478499971886893} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &235776220098759035 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4922478499971886893} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ae6f0d5ca1f0f42b6a38e38170777c16, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::InputLR diff --git a/Assets/InputLR.prefab.meta b/Assets/InputLR.prefab.meta new file mode 100644 index 0000000..7793a00 --- /dev/null +++ b/Assets/InputLR.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e5e1b2d573da547c18b40559867873ee +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/InputManagerLR.prefab b/Assets/InputManagerLR.prefab new file mode 100644 index 0000000..94c2d78 --- /dev/null +++ b/Assets/InputManagerLR.prefab @@ -0,0 +1,47 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &6888686618841934258 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1851593730206694447} + - component: {fileID: 7960844764031888550} + m_Layer: 0 + m_Name: InputManagerLR + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1851593730206694447 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6888686618841934258} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &7960844764031888550 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6888686618841934258} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5fc595679af414674be369cd3d5bc765, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::InputManagerLR + ActionAsset: {fileID: 0} diff --git a/Assets/InputManagerLR.prefab.meta b/Assets/InputManagerLR.prefab.meta new file mode 100644 index 0000000..b73b901 --- /dev/null +++ b/Assets/InputManagerLR.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d9d532ccbbbbe4c64a06e3b52f4faf45 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Test.unity b/Assets/Scenes/Test.unity index d118f24..88b049a 100644 --- a/Assets/Scenes/Test.unity +++ b/Assets/Scenes/Test.unity @@ -380,6 +380,7 @@ GameObject: m_Component: - component: {fileID: 653458609} - component: {fileID: 653458608} + - component: {fileID: 653458610} m_Layer: 0 m_Name: Directional Light m_TagString: Untagged @@ -467,6 +468,35 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!114 &653458610 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 653458607} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} + m_Name: + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.UniversalAdditionalLightData + m_UsePipelineSettings: 1 + m_AdditionalLightsShadowResolutionTier: 2 + m_CustomShadowLayers: 0 + m_LightCookieSize: {x: 1, y: 1} + m_LightCookieOffset: {x: 0, y: 0} + m_SoftShadowQuality: 0 + m_RenderingLayersMask: + serializedVersion: 0 + m_Bits: 1 + m_ShadowRenderingLayersMask: + serializedVersion: 0 + m_Bits: 1 + m_Version: 4 + m_LightLayerMask: 1 + m_ShadowLayerMask: 1 + m_RenderingLayers: 1 + m_ShadowRenderingLayers: 1 --- !u!1 &736825580 GameObject: m_ObjectHideFlags: 0 @@ -1120,6 +1150,7 @@ GameObject: - component: {fileID: 1396747591} - component: {fileID: 1396747590} - component: {fileID: 1396747589} + - component: {fileID: 1396747594} m_Layer: 0 m_Name: Capsule m_TagString: Untagged @@ -1215,10 +1246,10 @@ MonoBehaviour: m_SelectEntered: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 431147955} - m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine - m_MethodName: SetActive - m_Mode: 6 + - m_Target: {fileID: 1396747594} + m_TargetAssemblyTypeName: ItemCountDown, Assembly-CSharp + m_MethodName: GetGrab + m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine @@ -1230,10 +1261,10 @@ MonoBehaviour: m_SelectExited: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 431147955} - m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine - m_MethodName: SetActive - m_Mode: 6 + - m_Target: {fileID: 1396747594} + m_TargetAssemblyTypeName: ItemCountDown, Assembly-CSharp + m_MethodName: ExitGrab + m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine @@ -1451,6 +1482,20 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1396747587} m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} +--- !u!114 &1396747594 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1396747587} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 45dd4c486e2a64ef5a8f38d756b9dc2d, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::ItemCountDown + gameObjectRestore: {fileID: 1396747587} + grabItemTimeLimit: 5 --- !u!1001 &1615257418 PrefabInstance: m_ObjectHideFlags: 0 @@ -2084,6 +2129,120 @@ Transform: - {fileID: 999347490} m_Father: {fileID: 1118748834} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &8676663362647557757 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 3464648787695271206, guid: e5e1b2d573da547c18b40559867873ee, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3464648787695271206, guid: e5e1b2d573da547c18b40559867873ee, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3464648787695271206, guid: e5e1b2d573da547c18b40559867873ee, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3464648787695271206, guid: e5e1b2d573da547c18b40559867873ee, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3464648787695271206, guid: e5e1b2d573da547c18b40559867873ee, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3464648787695271206, guid: e5e1b2d573da547c18b40559867873ee, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3464648787695271206, guid: e5e1b2d573da547c18b40559867873ee, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3464648787695271206, guid: e5e1b2d573da547c18b40559867873ee, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3464648787695271206, guid: e5e1b2d573da547c18b40559867873ee, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3464648787695271206, guid: e5e1b2d573da547c18b40559867873ee, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4922478499971886893, guid: e5e1b2d573da547c18b40559867873ee, type: 3} + propertyPath: m_Name + value: InputLR + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: e5e1b2d573da547c18b40559867873ee, type: 3} +--- !u!1001 &9011766858270816510 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 1851593730206694447, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1851593730206694447, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1851593730206694447, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1851593730206694447, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1851593730206694447, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1851593730206694447, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1851593730206694447, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1851593730206694447, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1851593730206694447, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1851593730206694447, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6888686618841934258, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} + propertyPath: m_Name + value: InputManagerLR + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: d9d532ccbbbbe4c64a06e3b52f4faf45, type: 3} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 @@ -2095,3 +2254,5 @@ SceneRoots: - {fileID: 1615257418} - {fileID: 1637554823} - {fileID: 1118748834} + - {fileID: 9011766858270816510} + - {fileID: 8676663362647557757} diff --git a/Assets/Scripts/InputLR.cs b/Assets/Scripts/InputLR.cs new file mode 100644 index 0000000..dbdd07e --- /dev/null +++ b/Assets/Scripts/InputLR.cs @@ -0,0 +1,28 @@ +using UnityEngine; +using Unity.VRTemplate; + +public class InputLR : MonoBehaviour +{ + void Update() + { + if(InputManagerLR.PrimaryButtonR()) + { + OnPrimaryButtonR(); + } + + if(InputManagerLR.PrimaryButtonR_OnPress()) + { + OnPressPrimaryButtonR(); + } + } + + void OnPrimaryButtonR() + { + //邪魔になるためなし + } + + void OnPressPrimaryButtonR() + { + Debug.Log("押した瞬間"); + } +} diff --git a/Assets/Scripts/InputLR.cs.meta b/Assets/Scripts/InputLR.cs.meta new file mode 100644 index 0000000..230244d --- /dev/null +++ b/Assets/Scripts/InputLR.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ae6f0d5ca1f0f42b6a38e38170777c16 \ No newline at end of file diff --git a/Assets/Scripts/InputManagerLR.cs b/Assets/Scripts/InputManagerLR.cs new file mode 100644 index 0000000..cab8495 --- /dev/null +++ b/Assets/Scripts/InputManagerLR.cs @@ -0,0 +1,57 @@ +using UnityEngine; +using UnityEngine.InputSystem; + +public class InputManagerLR : MonoBehaviour +{ + static InputManagerLR instance; + + [SerializeField] + InputActionAsset ActionAsset; + + InputActionMap ActionMap; + InputAction m_PrimaryButtonR; + InputAction m_SecondaryButtonR; + InputAction m_PrimaryButtonL; + InputAction m_SecondaryButtonL; + + private void Awake() + { + instance = this; + GameObject.DontDestroyOnLoad(gameObject); + ActionMap = ActionAsset.FindActionMap("Test"); + m_PrimaryButtonR = ActionMap.FindAction("XR_PrimaryButtonR", throwIfNotFound: true); + m_PrimaryButtonL = ActionMap.FindAction("XR_PrimaryButtonL", throwIfNotFound: true); + m_SecondaryButtonR = ActionMap.FindAction("XR_SecondaryButtonR", throwIfNotFound: true); + m_SecondaryButtonL = ActionMap.FindAction("XR_SecondaryButtonL", throwIfNotFound: true); + } + + private void OnEnable() + { + ActionMap?.Enable(); + } + + private void OnDisable() + { + ActionMap?.Disable(); + } + + // Aボタン + public static bool PrimaryButtonR() => instance.m_PrimaryButtonR.IsPressed(); + public static bool PrimaryButtonR_OnPress() => instance.m_PrimaryButtonR.WasPressedThisFrame(); + public static bool PrimaryButtonR_OnRelease() => instance.m_PrimaryButtonR.WasReleasedThisFrame(); + + // Xボタン + public static bool PrimaryButtonL() => instance.m_PrimaryButtonL.IsPressed(); + public static bool PrimaryButtonL_OnPress() => instance.m_PrimaryButtonL.WasPressedThisFrame(); + public static bool PrimaryButtonL_OnRelease() => instance.m_PrimaryButtonL.WasReleasedThisFrame(); + + // Bボタン + public static bool SecondaryButtonR() => instance.m_SecondaryButtonR.IsPressed(); + public static bool SecondaryButtonR_OnPress() => instance.m_SecondaryButtonR.WasPressedThisFrame(); + public static bool SecondaryButtonR_OnRelease() => instance.m_SecondaryButtonR.WasReleasedThisFrame(); + + // Yボタン + public static bool SecondaryButtonL() => instance.m_SecondaryButtonL.IsPressed(); + public static bool SecondaryButtonL_OnPress() => instance.m_SecondaryButtonL.WasPressedThisFrame(); + public static bool SecondaryButtonL_OnRelease() => instance.m_SecondaryButtonL.WasReleasedThisFrame(); +} diff --git a/Assets/Scripts/InputManagerLR.cs.meta b/Assets/Scripts/InputManagerLR.cs.meta new file mode 100644 index 0000000..2d4dcb2 --- /dev/null +++ b/Assets/Scripts/InputManagerLR.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5fc595679af414674be369cd3d5bc765 \ No newline at end of file diff --git a/Assets/Scripts/ItemCountDown.cs b/Assets/Scripts/ItemCountDown.cs new file mode 100644 index 0000000..6e1d9b8 --- /dev/null +++ b/Assets/Scripts/ItemCountDown.cs @@ -0,0 +1,62 @@ +using UnityEngine; + +public class ItemCountDown : MonoBehaviour +{ + + public GameObject gameObjectRestore; //ゲームオブフェクトの復帰する座標を指定する + + private bool isGrabbed = false; + private bool isTouching = false; + + public float grabItemTimeLimit = 5.0f; //ゲームオブジェクトの位置がリセットされるまでのタイマー + private float timer; //スクリプト内のタイマーに用いる変数 + + void Start() + { + timer = 0.0f; + } + + public void GetGrab() + { + isGrabbed = true; + isTouching = true; + } + + public void ExitGrab() + { + isTouching = false; + } + + void Update() + { + //制限時間が0秒の場合は、位置のリセットを実行しない + if (grabItemTimeLimit != 0) + { + if (isGrabbed == true) + { + if (isTouching == false) + { + timer += Time.deltaTime; + + if (timer > grabItemTimeLimit) + { + //ゲームオブジェクトの速度をリセット + var rigidbody = GetComponent(); + rigidbody.linearVelocity = Vector3.zero; + //ゲームオブジェクトを指定位置に配置する + rigidbody.transform.position = gameObjectRestore.transform.position; + rigidbody.transform.rotation = gameObjectRestore.transform.rotation; + //ゲームオブジェクトは不動の状態に戻る + isGrabbed = false; + timer = 0.0f; + } + } + //プレイヤーが触っている場合はカウントダウンをリセット + else + { + timer = 0.0f; + } + } + } + } +} diff --git a/Assets/Scripts/ItemCountDown.cs.meta b/Assets/Scripts/ItemCountDown.cs.meta new file mode 100644 index 0000000..5ef5cd6 --- /dev/null +++ b/Assets/Scripts/ItemCountDown.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 45dd4c486e2a64ef5a8f38d756b9dc2d \ No newline at end of file