예제 #1
0
        public AudioClip LoadAudioClip(string name)
        {
            AudioClip ac = null;

            clipCache.TryGetValue(name, out ac);
            if (ac == null)
            {
                ac = AssetsManager.Load <AudioClip>("Sound/" + name);
                if (ac != null)
                {
                    clipCache.Add(name, ac);
                }
            }

            return(ac);
        }
예제 #2
0
        public void ShowUI <T> (bool bPushHistory = true, Dictionary <string, object> varList = null) where T : UIDialog
        {
            if (mCurrentDialog != null)
            {
                mCurrentDialog.gameObject.SetActive(false);
                mCurrentDialog = null;
            }

            string     name = typeof(T).ToString();
            GameObject uiObject;

            if (!mAllUIs.TryGetValue(name, out uiObject))
            {
                string perfbName = "UI/Dialog/" + typeof(T).ToString();
                Debug.Log(perfbName);
                GameObject perfb = AssetsManager.LoadPrefabs <GameObject> (perfbName);
                uiObject      = GameObject.Instantiate(perfb);
                uiObject.name = name;
                uiObject.AddComponent <T> ();
                uiObject.transform.SetParent(mDialog.transform);

                mAllUIs.Add(name, uiObject);
            }
            else
            {
                uiObject.SetActive(true);
            }

            if (uiObject)
            {
                T panel = uiObject.GetComponent <T> ();
                if (varList != null)
                {
                    panel.mUserData = varList;
                }

                mCurrentDialog = panel;

                uiObject.SetActive(true);

                if (bPushHistory)
                {
                    mDialogs.Enqueue(panel);
                }
            }
        }
예제 #3
0
        public void ShowScene <T> (Dictionary <string, object> varList = null) where T : BaseScene
        {
            if (mCurrentScene != null)
            {
                mCurrentScene.gameObject.SetActive(false);

                Debug.Log("destroy");
                mCurrentScene = null;
            }

            string     name = typeof(T).ToString();
            GameObject uiObject;

            if (!mAllScenes.TryGetValue(name, out uiObject))
            {
                Debug.Log("Poruduce new scene");
                string perfbName = "Scenes/" + typeof(T).ToString();
                Debug.Log(perfbName);
                GameObject perfb = AssetsManager.LoadPrefabs <GameObject> (perfbName);
                uiObject      = GameObject.Instantiate(perfb);
                uiObject.name = name;
                uiObject.AddComponent <T> ();
                uiObject.transform.SetParent(transform);

                mAllScenes.Add(name, uiObject);
            }
            else
            {
                uiObject.SetActive(true);
            }

            if (uiObject)
            {
                T scene = uiObject.GetComponent <T> ();
                if (varList != null)
                {
                    scene.mUserData = varList;
                }

                mCurrentScene = scene;

                uiObject.SetActive(true);
            }
        }
예제 #4
0
        public void ShowPanel <T> (Dictionary <string, object> varList = null) where T : UIPanel
        {
            string name = typeof(T).ToString();

            Debug.Log(name);

            var        panelTran = mPanel.transform.Find(name);
            GameObject uiObject;

            if (panelTran == null)
            {
                string     perfbName = "UI/Panel/" + typeof(T).ToString();
                GameObject perfb     = AssetsManager.LoadPrefabs <GameObject> (perfbName);
                if (perfb == null)
                {
                    Debug.Log("UIPanel Can`t Find Perfab");
                }
                uiObject      = GameObject.Instantiate(perfb);
                uiObject.name = name;
                uiObject.AddComponent <T> ();
                uiObject.transform.SetParent(mPanel.transform);
            }
            else
            {
                uiObject = panelTran.gameObject;
            }
            if (uiObject)
            {
                T panel = uiObject.GetComponent <T> ();
                if (varList != null)
                {
                    panel.mUserData = varList;
                }

                uiObject.SetActive(true);
            }
        }
예제 #5
0
        public void ShowBox <T> (Dictionary <string, object> varList = null) where T : UIBox
        {
            string name = typeof(T).ToString();

            var        panelTran = mBox.transform.Find(name);
            GameObject uiObject;

            if (panelTran == null)
            {
                string     perfbName = "UI/Box/" + typeof(T).ToString();
                GameObject perfb     = AssetsManager.LoadPrefabs <GameObject> (perfbName);
                uiObject      = GameObject.Instantiate(perfb);
                uiObject.name = name;
                uiObject.AddComponent <T> ();
                uiObject.transform.SetParent(mBox.transform);
            }
            else
            {
                uiObject = panelTran.gameObject;
            }
            if (uiObject)
            {
                T box = uiObject.GetComponent <T> ();
                if (varList != null)
                {
                    box.mUserData = varList;
                }

                if (mCurrentBox)
                {
                    mCurrentBox.gameObject.SetActive(false);
                }

                uiObject.SetActive(true);
                mCurrentBox = box;
            }
        }