コード例 #1
0
 void Awake()
 {
     if (s_instance != null && s_instance != this)
     {
         throw new System.Exception("There should only be one " + this.GetType());
     }
     s_instance = this;
 }
コード例 #2
0
 private void DoTimer()
 {
     if (repeat)
     {
         Chrono.setTimeout(DoTimer, (long)(seconds * 1000));
     }
     Chrono.ToDo todo = Chrono.setTimeout(whatToActivate.Data, (long)(seconds * 1000));
     todo.who      = this;
     todo.activate = !deactivate;
 }
コード例 #3
0
 public static Chrono Instance()
 {
     if (s_instance == null)
     {
         Object[] objs = FindObjectsOfType(typeof(Chrono));                  // find the instance
         for (int i = 0; i < objs.Length; ++i)
         {
             if (objs[i].GetType() == typeof(Chrono))
             {
                 s_instance = objs[i] as Chrono; break;
             }
         }
         if (s_instance == null)
         {                                           // if it doesn't exist
             GameObject g = new GameObject("<" + typeof(Chrono).Name + ">");
             s_instance = g.AddComponent <Chrono>(); // create one
         }
     }
     return(s_instance);
 }
コード例 #4
0
 /// <summary>Allows implicit conversion of lambda expressions and delegates. Same as Chrono.setTimeout, this method is here to prevent warnings.</summary>
 /// <param name="action">Action. what to do</param>
 /// <param name="delayMilliseconds">Delay milliseconds. in how-many-milliseconds to do it</param>
 public static void setTimeout(System.Action action, long delayMilliseconds)
 {
     Chrono.setTimeout(action, delayMilliseconds);
 }