Пример #1
0
    public void remove(IPausable p)
    {
        int h = p.GetHashCode();

        if (p.isSceneOnly())
        {
            for (int i = 0, c = sceneOnly.Count; i < c; ++i)
            {
                if (h == sceneOnly[i].GetHashCode())
                {
                    sceneOnly.RemoveAt(i);
                    sceneOnlyMonos.RemoveAt(i);
                    break;
                }
            }
        }
        else
        {
            for (int i = 0, c = durables.Count; i < c; ++i)
            {
                if (h == durables[i].GetHashCode())
                {
                    durables.RemoveAt(i);
                    durablesMonos.RemoveAt(i);
                    break;
                }
            }
        }
    }
Пример #2
0
 public void register(IPausable p, GameObject go)
 {
     if (p.isSceneOnly())
     {
         sceneOnly.Add(p);
         sceneOnlyMonos.Add(go.GetComponents <MonoBehaviour>());
     }
     else
     {
         durables.Add(p);
         durablesMonos.Add(go.GetComponents <MonoBehaviour>());
     }
 }
Пример #3
0
 /// <summary>
 /// Register the specified MonoBehaviour into the pausable components list
 /// Call this method in Start(). Calling from Awake() will fail to correctly get children components.
 /// </summary>
 /// <param name="p">Pausable implementation</param>
 /// <param name="mono">MonoBehaviour</param>
 public void register(IPausable p, MonoBehaviour mono)
 {
     MonoBehaviour[] monoArray = new MonoBehaviour[1];
     monoArray[0] = mono;
     if (p.isSceneOnly())
     {
         sceneOnly.Add(p);
         sceneOnlyMonos.Add(monoArray);
     }
     else
     {
         durables.Add(p);
         durablesMonos.Add(monoArray);
     }
 }
Пример #4
0
    /// <summary>
    /// Register the specified gameobject into the pausable components list
    /// Call this method in Start(). Calling from Awake() will fail to correctly get children components.
    /// </summary>
    /// <param name="p">Pausable implementation</param>
    /// <param name="go">GameObject</param>
    public void register(IPausable p, GameObject go)
    {
        // extract all MonoBehaviour components in one big array
        MonoBehaviour[] comps    = go.GetComponentsInChildren <MonoBehaviour>();
        MonoBehaviour[] combined = new MonoBehaviour[comps.Length];
        Array.Copy(comps, 0, combined, 0, comps.Length);

        /*MonoBehaviour[] comps = go.GetComponents<MonoBehaviour>();
         * MonoBehaviour[] compsChildren = go.GetComponentsInChildren<MonoBehaviour>();
         * MonoBehaviour[] combined = new MonoBehaviour[comps.Length + compsChildren.Length];
         * Array.Copy(comps, 0, combined, 0, comps.Length);
         * Array.Copy(compsChildren, 0, combined, comps.Length, compsChildren.Length);*/

        if (p.isSceneOnly())
        {
            sceneOnly.Add(p);
            sceneOnlyMonos.Add(combined);
        }
        else
        {
            durables.Add(p);
            durablesMonos.Add(combined);
        }
    }