Example #1
0
 public virtual void Show(bool isshow)
 {
     if (null != gameObject)
     {
         U3DMod.SetActive(gameObject, isshow);
     }
 }
Example #2
0
    /// <summary>
    /// 创建Hud
    /// </summary>
    /// <returns></returns>
    public T CreateHud <T>() where T : UIObject
    {
        T t = ResourceManager.New <T>(string.Format("UI/{0}", GetNameFromType(typeof(T))));

        U3DMod.AddChild(hudRoot, t.gameObject);
        return(t);
    }
Example #3
0
        /// <summary>
        /// 显示窗口
        /// 1用缓存
        /// 2用context数据
        /// 3重写生成
        /// </summary>
        /// <returns></returns>
        public T ShowWindow <T>(GameObject root = null) where T : UIWndBase
        {
            if (mWindowDic.ContainsKey(typeof(T)))
            {
                mWindowDic[typeof(T)].Show();
                return(mWindowDic[typeof(T)] as T);
            }
            else
            {
                //待修改
                GameObject obj = AssetBundleMgr.Instance.LoadUIPerfab(GetNameFromType(typeof(T)));
                if (root == null)
                {
                    U3DMod.AddChild(UiRoot, obj);
                }
                else
                {
                    U3DMod.AddChild(root, obj);
                }
                T t = obj.AddComponent <T>();
                t.OnInit();
                RegisterWindow(t);

                if (mContextDic.ContainsKey(typeof(T)))
                {
                    t.RefreshData(mContextDic[typeof(T)]);
                }
                else
                {
                    RegisterContext(typeof(T), t.RefreshData());
                }
                t.Show();
                return(t);
            }
        }
Example #4
0
 private void OnCancelHandler(GameObject o)
 {
     U3DMod.SetActive(this.gameObject, false);
     if (callback != null)
     {
         callback.Invoke(MsgResult.Cancel);
     }
     Destroy();
 }
Example #5
0
 public void Despawn(U3DObject uobj)
 {
     if (spwanList.Contains(uobj))
     {
         U3DMod.AddChild(null, uobj.gameObject, true);
         uobj.Hide();
         spwanList.Remove(uobj);
         despawnList.Add(uobj);
     }
 }
Example #6
0
 public virtual void Destroy()
 {
     if (DestroyHandler != null)
     {
         DestroyHandler(this);
     }
     if (gameObject != null)
     {
         U3DMod.Destroy(gameObject);
     }
 }
Example #7
0
 public virtual bool isShow()
 {
     if (gameObject != null)
     {
         return(U3DMod.isActive(gameObject));
     }
     else
     {
         return(false);
     }
 }
Example #8
0
    public UILoading ShowLoading()
    {
        if (mLoading != null)
        {
            return(mLoading);
        }

        mLoading = ResourceManager.New <UILoading>(string.Format("UI/{0}", GetNameFromType(typeof(UILoading))));
        U3DMod.AddChild(uiRoot, mLoading.gameObject);
        mLoading.progresPersent = 0;
        return(mLoading);
    }
Example #9
0
    /// <summary>
    /// 显示窗口
    /// </summary>
    /// <returns></returns>
    public T ShowWindow <T>() where T : UIWndBase
    {
        if (mWindowDic.ContainsKey(typeof(T)))
        {
            mWindowDic[typeof(T)].Show(true);
            mWindowDic[typeof(T)].gameObject.SetActive(true);
            mWindowDic[typeof(T)].transform.position = Vector3.zero;
            return(mWindowDic[typeof(T)] as T);
        }

        T t = ResourceManager.New <T>(string.Format("Prefabs/Ui/Pop/{0}", GetNameFromType(typeof(T))));

        U3DMod.AddChild(uiRoot, t.gameObject);
        t.gameObject.SetActive(true);
        t.transform.position = Vector3.zero;
        RegisterWindow(t);
        return(t);
    }
Example #10
0
        /// <summary>
        /// 加载Resources对象
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static T New <T>(string path) where T : Object
        {
            if (!Instance.mCacheDic.ContainsKey(path))
            {
                T res = Resources.Load <T>(path);
                if (res == null)
                {
                    DebugMod.LogError("can't find res from " + path);
                    return(null);
                }
                Instance.mCacheDic[path] = new ResCache()
                {
                    resCache = (Object)res
                };
            }

            T t = U3DMod.Clone <T>(Instance.mCacheDic[path].resCache);

            return(t);
        }
Example #11
0
        public U3DObject SpawnOne()
        {
            U3DObject uobj = null;

            if (despawnList.Count > 0)
            {
                spwanList.Add(despawnList[0]);
                uobj = despawnList[0];
                despawnList.Remove(uobj);
                uobj.DespawnHandler   = Despawn;
                uobj.OnDestroyHandler = OnDestroy;
            }
            else if (spwanList.Count > 0)
            {
                uobj = U3DMod.Clone <U3DObject>(spwanList[0]);
                spwanList.Add(uobj);
                uobj.DespawnHandler   = Despawn;
                uobj.OnDestroyHandler = OnDestroy;
            }
            return(uobj);
        }
Example #12
0
 public virtual void DestroyThisComponent()
 {
     U3DMod.Destroy(this);
 }
Example #13
0
 public void ClearAllHud()
 {
     U3DMod.SetActive(hudRoot, true);
     hudRoot.transform.DestroyChildren();
 }