Advertisement
Muk99

Example

Jan 13th, 2015
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. [System.Serializable]
  6. public class MyClass {
  7.     public string myString; //Must be the first declared varible, this will allow name on array and lists
  8.     public int myInt;
  9.     public float myFloat;
  10.     public GameObject myGO;
  11.     public Transform myTransform;
  12. }
  13.  
  14. [System.Serializable]
  15. public class MyOtherClass {
  16.     public string myOtherString;
  17.     public int myOtherInt;
  18.     public float myOtherFloat;
  19.     public GameObject myOtherGO;
  20.     public Transform myOtherTransform;
  21. }
  22.  
  23.  
  24. [SelectionBase]
  25. public class Example : MonoBehaviour {
  26.  
  27.     [Header("Example Class")]
  28.  
  29.     [Range (-50, 50)]
  30.     public int blockedInt;
  31.  
  32.     public GameObject someGO;
  33.  
  34.     [Space(10)]
  35.     //Will add some space on the inspector
  36.  
  37.     public List <MyClass> myClass;
  38.     public MyOtherClass[] myOtherClass;
  39.  
  40.     private Dictionary <string, MyClass> items;
  41.  
  42.     [ContextMenu ("Do Something")]
  43.     void Hue () {
  44.         print ("Sucefully");
  45.     }
  46.  
  47.     void Start () {
  48.         items = new Dictionary <string , MyClass> ();
  49.         for (int i = 0; i < myClass.Count; i ++){
  50.             items.Add (myClass[i].myString, myClass[i]);
  51.         }
  52.     }
  53.  
  54.     void Update () {
  55.         bool myBool = true;
  56.  
  57.         //This will change bool value
  58.         myBool ^= true;
  59.     }
  60.  
  61.     void Reset () {
  62.         //Called every time script is reseted by the inspector
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement