Advertisement
Guest User

Untitled

a guest
Sep 18th, 2022
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. /*
  2. *
  3. * Adventure Creator
  4. * by Chris Burton, 2013-2020
  5. *
  6. * "ActionTemplate.cs"
  7. *
  8. * This is a blank action template.
  9. *
  10. */
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using UnityEngine;
  14. using AC;
  15. using UnityEngine.UI;
  16. #if UNITY_EDITOR
  17. using UnityEditor;
  18. #endif
  19.  
  20. namespace AC
  21. {
  22.  
  23. [System.Serializable]
  24. public class ActionDisableObject : Action
  25. {
  26.  
  27. // Declare variables here
  28.  
  29. bool showBtn = true;
  30. public GameObject m_Object;
  31. public Text mytext;
  32.  
  33. public ActionDisableObject ()
  34. {
  35. this.isDisplayed = true;
  36. category = ActionCategory.Custom;
  37. title = "Disable or Enable Object";
  38. description = "Disable or Enable Object";
  39. }
  40.  
  41.  
  42. override public float Run ()
  43. {
  44. /*
  45. * This function is called when the action is performed.
  46. *
  47. * The float to return is the time that the game
  48. * should wait before moving on to the next action.
  49. * Return 0f to make the action instantenous.
  50. *
  51. * For actions that take longer than one frame,
  52. * you can return "defaultPauseTime" to make the game
  53. * re-run this function a short time later. You can
  54. * use the isRunning boolean to check if the action is
  55. * being run for the first time, eg:
  56. */
  57.  
  58.  
  59.  
  60. if (showBtn == true)
  61. {
  62. m_Object.SetActive(true);
  63. Debug.Log("set to true");
  64. }
  65. else
  66. {
  67. m_Object.SetActive(false);
  68. Debug.Log("set to false");
  69. }
  70. return 0f;
  71. }
  72.  
  73.  
  74.  
  75. public override void Skip ()
  76. {
  77. /*
  78. * This function is called when the Action is skipped, as a
  79. * result of the player invoking the "EndCutscene" input.
  80. *
  81. * It should perform the instructions of the Action instantly -
  82. * regardless of whether or not the Action itself has been run
  83. * normally yet. If this method is left blank, then skipping
  84. * the Action will have no effect. If this method is removed,
  85. * or if the Run() method call is left below, then skipping the
  86. * Action will cause it to run itself as normal.
  87. */
  88.  
  89. Run ();
  90. }
  91.  
  92.  
  93.  
  94.  
  95. #if UNITY_EDITOR
  96.  
  97. public override void ShowGUI ()
  98. {
  99. m_Object = (GameObject)EditorGUILayout.ObjectField("Object to Disable", m_Object, typeof(Object), true);
  100. showBtn = EditorGUILayout.Toggle("Toggle", showBtn);
  101.  
  102. AfterRunningOption ();
  103. }
  104.  
  105.  
  106. public override string SetLabel ()
  107. {
  108. // (Optional) Return a string used to describe the specific action's job.
  109.  
  110. return string.Empty;
  111. }
  112.  
  113. #endif
  114.  
  115. }
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement