Advertisement
Guest User

Adventure Creator - custom ActionList

a guest
Oct 14th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 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 Material 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 <Skybox>())
  43.             {
  44.                 objectToAffect.GetComponent <Skybox>().material = newSkybox;
  45.             }
  46.             return 0f;
  47.         }
  48.        
  49.         #if UNITY_EDITOR
  50.        
  51.         override public void ShowGUI ()
  52.         {
  53.             objectToAffect = (GameObject) EditorGUILayout.ObjectField ("GameObject to affect:", objectToAffect, typeof (GameObject), true);
  54.             newSkybox = (Material) EditorGUILayout.ObjectField ("New material:", newSkybox, typeof (Material), true);
  55.         }
  56.        
  57.        
  58.         public override string SetLabel ()
  59.         {
  60.             // Return a string used to describe the specific action's job.
  61.             if (objectToAffect)
  62.             {
  63.                 return (" (" + objectToAffect.name + " - " + newSkybox.ToString () + ")");
  64.             }
  65.             return "";
  66.         }
  67.         #endif
  68.        
  69.     }
  70.    
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement