예제 #1
0
 //销毁GameObject
 public void Destory(MonoBaseClass mb)
 {
     ReferenceMgr.Instance.Release(mb);
     if (mb?.Go)
     {
         UnityEngine.Object.Destroy(mb.Go);
     }
     mb?.OnDestory();
 }
예제 #2
0
 public virtual void OnClose()
 {
     Go?.SetActive(false);
     for (int i = 0; i < Childs.Count; i++)
     {
         MonoBaseClass childNode = Childs.Pop();
         ReferenceMgr.Instance.Release(childNode);
         childNode?.OnClose();
     }
     if (Go)
     {
         timerID = TimerMgr.Instance.AddTimer(destoryTime, 1, () =>
         {
             Object.DestroyImmediate(Go);
             OnDestory();
         });
     }
 }
예제 #3
0
    //创建嵌入式GameObject ----> 子GameObject
    public T Create <T>(string path, MonoBaseClass parent = null, Action <T> action = null) where T : MonoBaseClass, new()
    {
        T t = ReferenceMgr.Instance.Acquire <T>();

        if (null == t.Go)
        {
            parent?.Childs.Push(t);
            ResourcesMgr.Instance.LoadGameObj(path, parent?.Go.transform, (go) => {
                t.Go = go;
                t?.Awake();
                t?.OnOpen();
                action?.Invoke(t);
            });
        }
        else
        {
            t?.OnOpen();
            parent?.Childs.Push(t);
            action?.Invoke(t);
        }
        return(t);
    }
예제 #4
0
 //隐藏GameObject
 public void Hide(MonoBaseClass mb)
 {
     ReferenceMgr.Instance.Release(mb);
     mb?.OnClose();
 }
예제 #5
0
 //显示嵌入式GameObject ----> 子GameObject
 public T ShowChild <T>(string path, MonoBaseClass parent = null, Action <T> action = null) where T : MonoBaseClass, new()
 {
     return(CreateFactory.Instance.Create(path, parent, action));
 }