Advertisement
Guest User

Untitled

a guest
May 3rd, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. /*
  2. *
  3. * Adventure Creator
  4. * by Chris Burton, 2013-2016
  5. *
  6. * "ActionTemplate.cs"
  7. *
  8. * This is a blank action template.
  9. *
  10. */
  11.  
  12. using UnityEngine;
  13. using System.Collections;
  14.  
  15. #if UNITY_EDITOR
  16. using UnityEditor;
  17. #endif
  18.  
  19. namespace AC
  20. {
  21.  
  22. [System.Serializable]
  23. public class ActionChangeMenuButtonIcon : Action
  24. {
  25.  
  26. // Declare variables here
  27. [TextArea(1,1)]
  28. public string MenuName = "";
  29. [TextArea(1,1)]
  30. public string ElementName = "";
  31. public Texture myNewTexture;
  32.  
  33. public ActionChangeMenuButtonIcon ()
  34. {
  35. this.isDisplayed = true;
  36. category = ActionCategory.Custom;
  37. title = "Change Menu Icon";
  38. description = "Change menu icon.";
  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. if (!isRunning)
  59. {
  60. MenuElement myElement = AC.PlayerMenus.GetElementWithName (MenuName, ElementName).backgroundTexture;
  61. MenuGraphic myGraphic = (MenuGraphic) myElement;
  62. myGraphic.graphic.texture = myNewTexture;
  63. KickStarter.playerMenus.RecalculateAll ();
  64. myGraphic.SetNormalGraphicTexture (myNewTexture);
  65. }
  66. return 0f;
  67. }
  68.  
  69.  
  70. #if UNITY_EDITOR
  71.  
  72. override public void ShowGUI ()
  73. {
  74. // Action-specific Inspector GUI code here
  75. MenuName = EditorGUILayout.TextField ("Menu name:", MenuName);
  76. ElementName = EditorGUILayout.TextField ("Element name:", ElementName);
  77. myNewTexture = (Texture2D) EditorGUILayout.ObjectField ("Texture:", myNewTexture, typeof (Texture2D), false);
  78.  
  79.  
  80. AfterRunningOption ();
  81. }
  82.  
  83.  
  84. public override string SetLabel ()
  85. {
  86. // Return a string used to describe the specific action's job.
  87.  
  88. string labelAdd = "";
  89. return labelAdd;
  90. }
  91.  
  92. #endif
  93.  
  94. }
  95.  
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement