Advertisement
Guest User

Untitled

a guest
Sep 19th, 2022
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 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 int constantID;
  32. public bool showBtn;
  33. public Text mytext;
  34.  
  35. public ActionDisableObject ()
  36. {
  37. this.isDisplayed = true;
  38. category = ActionCategory.Custom;
  39. title = "Disable or Enable Object";
  40. description = "Disable or Enable Object";
  41. }
  42.  
  43.  
  44. override public float Run ()
  45. {
  46. /*
  47. * This function is called when the action is performed.
  48. *
  49. * The float to return is the time that the game
  50. * should wait before moving on to the next action.
  51. * Return 0f to make the action instantenous.
  52. *
  53. * For actions that take longer than one frame,
  54. * you can return "defaultPauseTime" to make the game
  55. * re-run this function a short time later. You can
  56. * use the isRunning boolean to check if the action is
  57. * being run for the first time, eg:
  58. */
  59.  
  60.  
  61.  
  62.  
  63. if (showBtn == true)
  64. {
  65. m_Object.SetActive(true);
  66. Debug.Log("true");
  67. }
  68. else
  69. {
  70. m_Object.SetActive(false);
  71. Debug.Log("false");
  72. }
  73. return 0f;
  74. }
  75.  
  76.  
  77.  
  78. public override void Skip ()
  79. {
  80. /*
  81. * This function is called when the Action is skipped, as a
  82. * result of the player invoking the "EndCutscene" input.
  83. *
  84. * It should perform the instructions of the Action instantly -
  85. * regardless of whether or not the Action itself has been run
  86. * normally yet. If this method is left blank, then skipping
  87. * the Action will have no effect. If this method is removed,
  88. * or if the Run() method call is left below, then skipping the
  89. * Action will cause it to run itself as normal.
  90. */
  91.  
  92. Run ();
  93. }
  94.  
  95.  
  96. override public void AssignValues()
  97. {
  98. m_Object = AssignFile(constantID, m_Object);
  99. }
  100.  
  101. #if UNITY_EDITOR
  102.  
  103. public override void ShowGUI ()
  104. {
  105. m_Object = (GameObject)EditorGUILayout.ObjectField("Object to Disable", m_Object, typeof(Object), true);
  106. showBtn = EditorGUILayout.Toggle("Toggle?", showBtn);
  107. constantID = FieldToID(m_Object, constantID);
  108. m_Object = IDToField(m_Object, constantID, true);
  109.  
  110. AfterRunningOption ();
  111. }
  112.  
  113.  
  114. public override string SetLabel ()
  115. {
  116. // (Optional) Return a string used to describe the specific action's job.
  117.  
  118. return string.Empty;
  119. }
  120.  
  121. #endif
  122.  
  123. }
  124.  
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement