Advertisement
Guest User

Untitled

a guest
Aug 16th, 2022
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 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 UnityEngine.UI;
  15. #if UNITY_EDITOR
  16. using UnityEditor;
  17. #endif
  18.  
  19. namespace AC
  20. {
  21.  
  22. [System.Serializable]
  23. public class ActionChangeFontColor : Action
  24. {
  25.  
  26. // Declare variables here
  27.  
  28. public Text mytext;
  29. public Color mycolor = Color.white;
  30. public Color fadeColor = Color.black;
  31. public int constantID;
  32. public float fadeTime = 2;
  33. public float fadeStart = 0;
  34. public GameObject objectToAffect;
  35.  
  36. public ActionChangeFontColor ()
  37. {
  38. this.isDisplayed = true;
  39. category = ActionCategory.Custom;
  40. title = "Change Font Color";
  41. description = "It changes the font color I guess.";
  42. }
  43.  
  44.  
  45. override public float Run ()
  46. {
  47. /*
  48. * This function is called when the action is performed.
  49. *
  50. * The float to return is the time that the game
  51. * should wait before moving on to the next action.
  52. * Return 0f to make the action instantenous.
  53. *
  54. * For actions that take longer than one frame,
  55. * you can return "defaultPauseTime" to make the game
  56. * re-run this function a short time later. You can
  57. * use the isRunning boolean to check if the action is
  58. * being run for the first time, eg:
  59. */
  60.  
  61. fadeStart = 0;
  62. if (fadeStart < fadeTime)
  63. {
  64.  
  65. fadeStart += Time.deltaTime * fadeTime;
  66. mytext.color = Color.Lerp(mycolor, fadeColor, fadeStart);
  67.  
  68. }
  69. return 0f;
  70. }
  71.  
  72.  
  73.  
  74. public override void Skip ()
  75. {
  76. /*
  77. * This function is called when the Action is skipped, as a
  78. * result of the player invoking the "EndCutscene" input.
  79. *
  80. * It should perform the instructions of the Action instantly -
  81. * regardless of whether or not the Action itself has been run
  82. * normally yet. If this method is left blank, then skipping
  83. * the Action will have no effect. If this method is removed,
  84. * or if the Run() method call is left below, then skipping the
  85. * Action will cause it to run itself as normal.
  86. */
  87.  
  88. Run ();
  89. }
  90.  
  91. override public void AssignValues ()
  92. {
  93. mytext = AssignFile (constantID, mytext);
  94. }
  95.  
  96.  
  97. #if UNITY_EDITOR
  98.  
  99. public override void ShowGUI ()
  100. {
  101. mytext = (Text) EditorGUILayout.ObjectField ("Text:", mytext, typeof (Text), false);
  102. mycolor = (Color) EditorGUILayout.ColorField ("Color:", mycolor);
  103. constantID = FieldToID (mytext, constantID);
  104. mytext = IDToField (mytext, constantID, true);
  105.  
  106.  
  107. AfterRunningOption ();
  108. }
  109.  
  110.  
  111. public override string SetLabel ()
  112. {
  113. // (Optional) Return a string used to describe the specific action's job.
  114.  
  115. return string.Empty;
  116. }
  117.  
  118. #endif
  119.  
  120. }
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement