summaryrefslogtreecommitdiff
path: root/Mage/Assets/Test/PhysicsExample/Scripts/Generic/BehaviourEnableDisable.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Mage/Assets/Test/PhysicsExample/Scripts/Generic/BehaviourEnableDisable.cs')
-rw-r--r--Mage/Assets/Test/PhysicsExample/Scripts/Generic/BehaviourEnableDisable.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/Mage/Assets/Test/PhysicsExample/Scripts/Generic/BehaviourEnableDisable.cs b/Mage/Assets/Test/PhysicsExample/Scripts/Generic/BehaviourEnableDisable.cs
new file mode 100644
index 0000000..7f07218
--- /dev/null
+++ b/Mage/Assets/Test/PhysicsExample/Scripts/Generic/BehaviourEnableDisable.cs
@@ -0,0 +1,29 @@
+using System.Collections;
+using UnityEngine;
+
+/// <summary>
+/// Enable/Disable a component periodically.
+/// </summary>
+public class BehaviourEnableDisable : MonoBehaviour
+{
+ public Behaviour m_BehaviourComponent;
+ public float m_TogglePeriod = 1f;
+
+ IEnumerator Start ()
+ {
+ yield return new WaitForSeconds (1f);
+
+ if (m_BehaviourComponent)
+ {
+ while (true)
+ {
+ // Flip the enabled state.
+ m_BehaviourComponent.enabled = !m_BehaviourComponent.enabled;
+
+ // Wait for specified period before toggling again.
+ yield return new WaitForSeconds (m_TogglePeriod);
+ }
+ }
+ }
+
+}