SHARE
TWEET

Untitled

a guest Oct 12th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 ActionChangeMenuIcon : 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 ActionChangeMenuIcon ()
  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);
  61. MenuGraphic myGraphic = (MenuGraphic) myElement;
  62. myGraphic.graphic.texture = myNewTexture;
  63. KickStarter.playerMenus.RecalculateAll ();
  64.             }
  65.             return 0f;
  66.         }
  67.        
  68.        
  69.         #if UNITY_EDITOR
  70.  
  71.         override public void ShowGUI ()
  72.         {
  73.             // Action-specific Inspector GUI code here
  74.             MenuName = EditorGUILayout.TextField ("Menu name:", MenuName);
  75.             ElementName = EditorGUILayout.TextField ("Element name:", ElementName);
  76.             myNewTexture = (Texture2D) EditorGUILayout.ObjectField ("Texture:", myNewTexture, typeof (Texture2D), false);
  77.  
  78.        
  79.         AfterRunningOption ();
  80.         }
  81.        
  82.  
  83.         public override string SetLabel ()
  84.         {
  85.             // Return a string used to describe the specific action's job.
  86.            
  87.             string labelAdd = "";
  88.             return labelAdd;
  89.         }
  90.  
  91.         #endif
  92.        
  93.     }
  94.  
  95. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top