Advertisement
Guest User

Adventure Creator - custom ActionList

a guest
Oct 13th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. /*
  2.  *
  3.  *  Adventure Creator
  4.  *  by Chris Burton, 2013-2015
  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 ActionSkybox : Action
  24.     {
  25.        
  26.         // Declare variables here
  27.         public GameObject objectToAffect;
  28.         public GameObject newSkybox;
  29.        
  30.        
  31.         public ActionSkybox ()
  32.         {
  33.             this.isDisplayed = true;
  34.             category = ActionCategory.Object;
  35.             title = "Change skybox";
  36.             description = "This action changes a camera's skybox material.";
  37.         }
  38.        
  39.        
  40.         override public float Run ()
  41.         {
  42.             if (objectToAffect && objectToAffect.GetComponent ())
  43.             {
  44.                 objectToAffect.GetComponent <Skybox>().material = newSkybox;
  45.             }
  46.         }
  47.        
  48.         #if UNITY_EDITOR
  49.  
  50.         override public void ShowGUI ()
  51.         {
  52.             objectToAffect = (GameObject) EditorGUILayout.ObjectField ("GameObject to affect:", objectToAffect, typeof (GameObject), true);
  53.             newSkybox = (GameObject) EditorGUILayout.ObjectField ("New material:", newSkybox, typeof (GameObject), true);
  54.         }
  55.        
  56.  
  57.         public override string SetLabel ()
  58.         {
  59.             // Return a string used to describe the specific action's job.
  60.             if (objectToAffect)
  61.             {
  62.                 return (" (" + objectToAffect.name + " - " + newSkybox.ToString () + ")");
  63.             }
  64.             return "";
  65.         }
  66.         #endif
  67.        
  68.     }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement