From 5a8fb0697d1c93748b39c1f146a191eec995fe7e Mon Sep 17 00:00:00 2001 From: RobertMa123 Date: Mon, 21 Oct 2024 09:46:07 -0400 Subject: [PATCH] Doors are now operated thru buttons --- Assets/Animations/Door.controller | 88 ++++--- Assets/Animations/DoorClose.anim | 2 +- Assets/Animations/DoorOpen.anim | 2 +- Assets/Scenes/BasicScene.unity | 378 +++++++++++++++------------- Assets/Scripts/Door.cs | 18 ++ Assets/Scripts/Door.cs.meta | 11 + Assets/Scripts/UI Buttons/Button.cs | 11 +- 7 files changed, 289 insertions(+), 221 deletions(-) create mode 100644 Assets/Scripts/Door.cs create mode 100644 Assets/Scripts/Door.cs.meta diff --git a/Assets/Animations/Door.controller b/Assets/Animations/Door.controller index 96f9522..d92b285 100644 --- a/Assets/Animations/Door.controller +++ b/Assets/Animations/Door.controller @@ -1,5 +1,30 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1101 &-8541944105379229200 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: OpenDoor + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 2003707095076494797} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.75 + m_HasExitTime: 1 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1101 &-8356219517044911158 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -35,7 +60,8 @@ AnimatorState: m_Name: Base m_Speed: 1 m_CycleOffset: 0 - m_Transitions: [] + m_Transitions: + - {fileID: 3801524749882099630} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -51,31 +77,6 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: ---- !u!1101 &-1825882741439241346 -AnimatorStateTransition: - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: - m_Conditions: - - m_ConditionMode: 1 - m_ConditionEvent: OpenDoor - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 2003707095076494797} - m_Solo: 0 - m_Mute: 0 - m_IsExit: 0 - serializedVersion: 3 - m_TransitionDuration: 0.25 - m_TransitionOffset: 0 - m_ExitTime: 0.75 - m_HasExitTime: 0 - m_HasFixedDuration: 1 - m_InterruptionSource: 0 - m_OrderedInterruption: 1 - m_CanTransitionToSelf: 1 --- !u!1107 &-818438656623888063 AnimatorStateMachine: serializedVersion: 6 @@ -90,13 +91,12 @@ AnimatorStateMachine: m_Position: {x: 300, y: 60, z: 0} - serializedVersion: 1 m_State: {fileID: 3988175026234841628} - m_Position: {x: 290, y: 320, z: 0} + m_Position: {x: 300, y: 150, z: 0} - serializedVersion: 1 m_State: {fileID: 2003707095076494797} - m_Position: {x: 290, y: 230, z: 0} + m_Position: {x: 300, y: 250, z: 0} m_ChildStateMachines: [] - m_AnyStateTransitions: - - {fileID: -1825882741439241346} + m_AnyStateTransitions: [] m_EntryTransitions: [] m_StateMachineTransitions: {} m_StateMachineBehaviours: [] @@ -160,6 +160,31 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: +--- !u!1101 &3801524749882099630 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 2 + m_ConditionEvent: OpenDoor + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 3988175026234841628} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.75 + m_HasExitTime: 1 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1102 &3988175026234841628 AnimatorState: serializedVersion: 6 @@ -170,7 +195,8 @@ AnimatorState: m_Name: DoorClose m_Speed: 1 m_CycleOffset: 0 - m_Transitions: [] + m_Transitions: + - {fileID: -8541944105379229200} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 diff --git a/Assets/Animations/DoorClose.anim b/Assets/Animations/DoorClose.anim index 968706f..40d0487 100644 --- a/Assets/Animations/DoorClose.anim +++ b/Assets/Animations/DoorClose.anim @@ -70,7 +70,7 @@ AnimationClip: m_Level: 0 m_CycleOffset: 0 m_HasAdditiveReferencePose: 0 - m_LoopTime: 1 + m_LoopTime: 0 m_LoopBlend: 0 m_LoopBlendOrientation: 0 m_LoopBlendPositionY: 0 diff --git a/Assets/Animations/DoorOpen.anim b/Assets/Animations/DoorOpen.anim index 89d68d6..a449ba6 100644 --- a/Assets/Animations/DoorOpen.anim +++ b/Assets/Animations/DoorOpen.anim @@ -70,7 +70,7 @@ AnimationClip: m_Level: 0 m_CycleOffset: 0 m_HasAdditiveReferencePose: 0 - m_LoopTime: 1 + m_LoopTime: 0 m_LoopBlend: 0 m_LoopBlendOrientation: 0 m_LoopBlendPositionY: 0 diff --git a/Assets/Scenes/BasicScene.unity b/Assets/Scenes/BasicScene.unity index d85696b..e3add67 100644 --- a/Assets/Scenes/BasicScene.unity +++ b/Assets/Scenes/BasicScene.unity @@ -1333,7 +1333,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4392ffc77a506104d80256dc28470f19, type: 3} m_Name: m_EditorClassIdentifier: - test: {fileID: 370492606} + test: {fileID: 0} colorChangeSpeed: 0.5 endColor: {r: 0, g: 0, b: 0, a: 0} --- !u!95 &33726348 @@ -2569,8 +2569,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 06139d0a49ec7124a9143ceeabf246c0, type: 3} m_Name: m_EditorClassIdentifier: - leftArrow: {fileID: 992329716} - rightArrow: {fileID: 1145431392} + leftArrow: {fileID: 0} + rightArrow: {fileID: 0} --- !u!850595691 &404504638 LightingSettings: m_ObjectHideFlags: 0 @@ -3140,6 +3140,171 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 844119475} m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!43 &851089372 +Mesh: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: pb_Mesh-39968(Clone) + serializedVersion: 11 + m_SubMeshes: + - serializedVersion: 2 + firstByte: 0 + indexCount: 36 + topology: 0 + baseVertex: 0 + firstVertex: 0 + vertexCount: 24 + localAABB: + m_Center: {x: -1, y: 1.625, z: -0.125} + m_Extent: {x: 1, y: 1.375, z: 0.125} + m_Shapes: + vertices: [] + shapes: [] + channels: [] + fullWeights: [] + m_BindPose: [] + m_BoneNameHashes: + m_RootBoneNameHash: 0 + m_BonesAABB: [] + m_VariableBoneCountWeights: + m_Data: + m_MeshCompression: 0 + m_IsReadable: 1 + m_KeepVertices: 1 + m_KeepIndices: 1 + m_IndexFormat: 0 + m_IndexBuffer: 000001000200010003000200040005000600050007000600080009000a0009000b000a000c000d000e000d000f000e00100011001200110013001200140015001600150017001600 + m_VertexData: + serializedVersion: 3 + m_VertexCount: 24 + m_Channels: + - stream: 0 + offset: 0 + format: 0 + dimension: 3 + - stream: 0 + offset: 12 + format: 0 + dimension: 3 + - stream: 0 + offset: 24 + format: 0 + dimension: 4 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 40 + format: 0 + dimension: 2 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + m_DataSize: 1152 + _typelessdata: 000000c00000803e0000000000000000000000000000803f000080bf0000000000000000000080bf000000400000803e000000000000803e0000000000000000000000000000803f000080bf0000000000000000000080bf000000000000803e000000c0000040400000000000000000000000000000803f000080bf0000000000000000000080bf000000400000404000000000000040400000000000000000000000000000803f000080bf0000000000000000000080bf0000000000004040000000000000803e000000000000803f000000000000000000000000000000000000803f000080bf000000000000803e000000000000803e000080be0000803f000000000000000000000000000000000000803f000080bf000080be0000803e0000000000004040000000000000803f000000000000000000000000000000000000803f000080bf00000000000040400000000000004040000080be0000803f000000000000000000000000000000000000803f000080bf000080be00004040000000000000803e000080be0000000000000000000080bf0000803f0000000000000000000080bf000000000000803e000000c00000803e000080be0000000000000000000080bf0000803f0000000000000000000080bf000000c00000803e0000000000004040000080be0000000000000000000080bf0000803f0000000000000000000080bf0000000000004040000000c000004040000080be0000000000000000000080bf0000803f0000000000000000000080bf000000c000004040000000c00000803e000080be000080bf00000000000000000000000000000000000080bf000080bf0000803e0000803e000000c00000803e00000000000080bf00000000000000000000000000000000000080bf000080bf000000000000803e000000c000004040000080be000080bf00000000000000000000000000000000000080bf000080bf0000803e00004040000000c00000404000000000000080bf00000000000000000000000000000000000080bf000080bf0000000000004040000000c00000404000000000000000000000803f000000000000803f0000000000000000000080bf000000c000000000000000000000404000000000000000000000803f000000000000803f0000000000000000000080bf0000000000000000000000c000004040000080be000000000000803f000000000000803f0000000000000000000080bf000000c0000080be0000000000004040000080be000000000000803f000000000000803f0000000000000000000080bf00000000000080be000000c00000803e000080be00000000000080bf00000000000080bf0000000000000000000080bf00000040000080be000000000000803e000080be00000000000080bf00000000000080bf0000000000000000000080bf00000000000080be000000c00000803e0000000000000000000080bf00000000000080bf0000000000000000000080bf0000004000000000000000000000803e0000000000000000000080bf00000000000080bf0000000000000000000080bf0000000000000000 + m_CompressedMesh: + m_Vertices: + m_NumItems: 0 + m_Range: 0 + m_Start: 0 + m_Data: + m_BitSize: 0 + m_UV: + m_NumItems: 0 + m_Range: 0 + m_Start: 0 + m_Data: + m_BitSize: 0 + m_Normals: + m_NumItems: 0 + m_Range: 0 + m_Start: 0 + m_Data: + m_BitSize: 0 + m_Tangents: + m_NumItems: 0 + m_Range: 0 + m_Start: 0 + m_Data: + m_BitSize: 0 + m_Weights: + m_NumItems: 0 + m_Data: + m_BitSize: 0 + m_NormalSigns: + m_NumItems: 0 + m_Data: + m_BitSize: 0 + m_TangentSigns: + m_NumItems: 0 + m_Data: + m_BitSize: 0 + m_FloatColors: + m_NumItems: 0 + m_Range: 0 + m_Start: 0 + m_Data: + m_BitSize: 0 + m_BoneIndices: + m_NumItems: 0 + m_Data: + m_BitSize: 0 + m_Triangles: + m_NumItems: 0 + m_Data: + m_BitSize: 0 + m_UVInfo: 0 + m_LocalAABB: + m_Center: {x: -1, y: 1.625, z: -0.125} + m_Extent: {x: 1, y: 1.375, z: 0.125} + m_MeshUsageFlags: 0 + m_CookingOptions: 30 + m_BakedConvexCollisionMesh: + m_BakedTriangleCollisionMesh: + m_MeshMetrics[0]: 1 + m_MeshMetrics[1]: 1 + m_MeshOptimizationFlags: 1 + m_StreamData: + serializedVersion: 2 + offset: 0 + size: 0 + path: --- !u!43 &862557441 Mesh: m_ObjectHideFlags: 0 @@ -7439,7 +7604,7 @@ Rigidbody: m_ImplicitTensor: 1 m_UseGravity: 0 m_IsKinematic: 0 - m_Interpolate: 0 + m_Interpolate: 1 m_Constraints: 112 m_CollisionDetection: 2 --- !u!135 &1048373887 @@ -7764,11 +7929,6 @@ 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} @@ -10649,10 +10809,22 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 25c3c966e71d46e44a5906cb03f23a43, type: 3} m_Name: m_EditorClassIdentifier: - deadTime: 1 + deadTime: 0.1 onPressed: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 1913922102} + m_TargetAssemblyTypeName: Door, Assembly-CSharp + m_MethodName: Operate + 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 onReleased: m_PersistentCalls: m_Calls: [] @@ -10844,171 +11016,6 @@ MonoBehaviour: m_Teleporting: m_PersistentCalls: m_Calls: [] ---- !u!43 &1293879480 -Mesh: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh-39968 - serializedVersion: 11 - m_SubMeshes: - - serializedVersion: 2 - firstByte: 0 - indexCount: 36 - topology: 0 - baseVertex: 0 - firstVertex: 0 - vertexCount: 24 - localAABB: - m_Center: {x: -1, y: 1.625, z: -0.125} - m_Extent: {x: 1, y: 1.375, z: 0.125} - m_Shapes: - vertices: [] - shapes: [] - channels: [] - fullWeights: [] - m_BindPose: [] - m_BoneNameHashes: - m_RootBoneNameHash: 0 - m_BonesAABB: [] - m_VariableBoneCountWeights: - m_Data: - m_MeshCompression: 0 - m_IsReadable: 1 - m_KeepVertices: 1 - m_KeepIndices: 1 - m_IndexFormat: 0 - m_IndexBuffer: 000001000200010003000200040005000600050007000600080009000a0009000b000a000c000d000e000d000f000e00100011001200110013001200140015001600150017001600 - m_VertexData: - serializedVersion: 3 - m_VertexCount: 24 - m_Channels: - - stream: 0 - offset: 0 - format: 0 - dimension: 3 - - stream: 0 - offset: 12 - format: 0 - dimension: 3 - - stream: 0 - offset: 24 - format: 0 - dimension: 4 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 40 - format: 0 - dimension: 2 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - m_DataSize: 1152 - _typelessdata: 000000c00000803e0000000000000000000000000000803f000080bf0000000000000000000080bf000000400000803e000000000000803e0000000000000000000000000000803f000080bf0000000000000000000080bf000000000000803e000000c0000040400000000000000000000000000000803f000080bf0000000000000000000080bf000000400000404000000000000040400000000000000000000000000000803f000080bf0000000000000000000080bf0000000000004040000000000000803e000000000000803f000000000000000000000000000000000000803f000080bf000000000000803e000000000000803e000080be0000803f000000000000000000000000000000000000803f000080bf000080be0000803e0000000000004040000000000000803f000000000000000000000000000000000000803f000080bf00000000000040400000000000004040000080be0000803f000000000000000000000000000000000000803f000080bf000080be00004040000000000000803e000080be0000000000000000000080bf0000803f0000000000000000000080bf000000000000803e000000c00000803e000080be0000000000000000000080bf0000803f0000000000000000000080bf000000c00000803e0000000000004040000080be0000000000000000000080bf0000803f0000000000000000000080bf0000000000004040000000c000004040000080be0000000000000000000080bf0000803f0000000000000000000080bf000000c000004040000000c00000803e000080be000080bf00000000000000000000000000000000000080bf000080bf0000803e0000803e000000c00000803e00000000000080bf00000000000000000000000000000000000080bf000080bf000000000000803e000000c000004040000080be000080bf00000000000000000000000000000000000080bf000080bf0000803e00004040000000c00000404000000000000080bf00000000000000000000000000000000000080bf000080bf0000000000004040000000c00000404000000000000000000000803f000000000000803f0000000000000000000080bf000000c000000000000000000000404000000000000000000000803f000000000000803f0000000000000000000080bf0000000000000000000000c000004040000080be000000000000803f000000000000803f0000000000000000000080bf000000c0000080be0000000000004040000080be000000000000803f000000000000803f0000000000000000000080bf00000000000080be000000c00000803e000080be00000000000080bf00000000000080bf0000000000000000000080bf00000040000080be000000000000803e000080be00000000000080bf00000000000080bf0000000000000000000080bf00000000000080be000000c00000803e0000000000000000000080bf00000000000080bf0000000000000000000080bf0000004000000000000000000000803e0000000000000000000080bf00000000000080bf0000000000000000000080bf0000000000000000 - m_CompressedMesh: - m_Vertices: - m_NumItems: 0 - m_Range: 0 - m_Start: 0 - m_Data: - m_BitSize: 0 - m_UV: - m_NumItems: 0 - m_Range: 0 - m_Start: 0 - m_Data: - m_BitSize: 0 - m_Normals: - m_NumItems: 0 - m_Range: 0 - m_Start: 0 - m_Data: - m_BitSize: 0 - m_Tangents: - m_NumItems: 0 - m_Range: 0 - m_Start: 0 - m_Data: - m_BitSize: 0 - m_Weights: - m_NumItems: 0 - m_Data: - m_BitSize: 0 - m_NormalSigns: - m_NumItems: 0 - m_Data: - m_BitSize: 0 - m_TangentSigns: - m_NumItems: 0 - m_Data: - m_BitSize: 0 - m_FloatColors: - m_NumItems: 0 - m_Range: 0 - m_Start: 0 - m_Data: - m_BitSize: 0 - m_BoneIndices: - m_NumItems: 0 - m_Data: - m_BitSize: 0 - m_Triangles: - m_NumItems: 0 - m_Data: - m_BitSize: 0 - m_UVInfo: 0 - m_LocalAABB: - m_Center: {x: -1, y: 1.625, z: -0.125} - m_Extent: {x: 1, y: 1.375, z: 0.125} - m_MeshUsageFlags: 0 - m_CookingOptions: 30 - m_BakedConvexCollisionMesh: - m_BakedTriangleCollisionMesh: - m_MeshMetrics[0]: 1 - m_MeshMetrics[1]: 1 - m_MeshOptimizationFlags: 1 - m_StreamData: - serializedVersion: 2 - offset: 0 - size: 0 - path: --- !u!43 &1632050218 Mesh: m_ObjectHideFlags: 0 @@ -11272,6 +11279,7 @@ GameObject: - component: {fileID: 1913922098} - component: {fileID: 1913922097} - component: {fileID: 1913922096} + - component: {fileID: 1913922102} m_Layer: 0 m_Name: Door m_TagString: Untagged @@ -11336,7 +11344,7 @@ MeshCollider: serializedVersion: 5 m_Convex: 0 m_CookingOptions: 30 - m_Mesh: {fileID: 1293879480} + m_Mesh: {fileID: 851089372} --- !u!33 &1913922098 MeshFilter: m_ObjectHideFlags: 10 @@ -11344,7 +11352,7 @@ MeshFilter: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1913922094} - m_Mesh: {fileID: 1293879480} + m_Mesh: {fileID: 851089372} --- !u!23 &1913922099 MeshRenderer: m_ObjectHideFlags: 0 @@ -11626,12 +11634,24 @@ MonoBehaviour: m_AreaError: 15 m_PreserveMeshAssetOnDestroy: 0 assetGuid: - m_Mesh: {fileID: 1293879480} + m_Mesh: {fileID: 851089372} m_VersionIndex: 6400 m_IsSelectable: 1 m_SelectedFaces: m_SelectedEdges: [] m_SelectedVertices: +--- !u!114 &1913922102 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1913922094} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a0751b9dff1a0a646bebfd5a1c9c52c2, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!43 &1918244054 Mesh: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Door.cs b/Assets/Scripts/Door.cs new file mode 100644 index 0000000..aaf8766 --- /dev/null +++ b/Assets/Scripts/Door.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Door : MonoBehaviour +{ + private Animator animator; + private bool open = false; + private void Start() + { + animator = GetComponent(); + } + public void Operate() + { + open = !open; + animator.SetBool("OpenDoor", open); + } +} diff --git a/Assets/Scripts/Door.cs.meta b/Assets/Scripts/Door.cs.meta new file mode 100644 index 0000000..d56b13c --- /dev/null +++ b/Assets/Scripts/Door.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a0751b9dff1a0a646bebfd5a1c9c52c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI Buttons/Button.cs b/Assets/Scripts/UI Buttons/Button.cs index 642de9a..d30b988 100644 --- a/Assets/Scripts/UI Buttons/Button.cs +++ b/Assets/Scripts/UI Buttons/Button.cs @@ -6,37 +6,30 @@ public class Button : MonoBehaviour { - //Time that the button is set inactive after release public float deadTime = 1.0f; - //Bool used to lock down button during its set dead time private bool _deadTimeActive = false; - //public Unity Events we can use in the editor and tie other functions to. public UnityEvent onPressed, onReleased; - //Checks if the current collider entering is the Button and sets off OnPressed event. private void OnTriggerEnter(Collider other) { if (other.tag == "Button" && !_deadTimeActive) { onPressed?.Invoke(); - Debug.Log("I have been pressed"); + Debug.Log("button pressed"); } } - //Checks if the current collider exiting is the Button and sets off OnReleased event. - //It will also call a Coroutine to make the button inactive for however long deadTime is set to. private void OnTriggerExit(Collider other) { if (other.tag == "Button" && !_deadTimeActive) { onReleased?.Invoke(); - Debug.Log("I have been released"); + Debug.Log("button released"); StartCoroutine(WaitForDeadTime()); } } - //Locks button activity until deadTime has passed and reactivates button activity. IEnumerator WaitForDeadTime() { _deadTimeActive = true;