예제 #1
0
        private IEnumerator <int> AsyncLoadData(string loadPath = null)
        {
            UIInfoData _uiInfoData = null;

            UnityEngine.Object _prefabObj = null;
            GameObject         _uiObject  = null;

            if (stackOpenUIs != null && stackOpenUIs.Count > 0)
            {
                do
                {
                    _uiInfoData = stackOpenUIs.Pop();
                    _prefabObj  = Resources.Load(_uiInfoData.Path);
                    if (_prefabObj != null)
                    {
                        //_uiObject = NGUITools.AddChild(Game.Instance.mainUICamera.gameObject, _prefabObj as GameObject);
                        _uiObject = MonoBehaviour.Instantiate(_prefabObj) as GameObject;
                        if (loadPath != null)
                        {
                            Vector3 rotTemp = _uiObject.transform.localScale;
                            Vector3 posTem  = _uiObject.transform.localPosition;
                            _uiObject.transform.parent = GameObject.Find(loadPath).transform;//加载预制件的路径
                            //_uiObject.transform.
                            _uiObject.transform.localScale    = rotTemp;
                            _uiObject.transform.localPosition = posTem;
                        }
                        _uiObject.transform.localPosition = new Vector3();
                        BaseUI _baseUI = _uiObject.GetComponent <BaseUI>();
                        if (null == _baseUI)
                        {
                            _baseUI = _uiObject.AddComponent(_uiInfoData.ScriptType) as BaseUI;
                        }
                        if (null != _baseUI)
                        {
                            _baseUI.SetUIWhenOpening(_uiInfoData.UIParams);
                        }
                        dicOpenUIs.Add(_uiInfoData.UIType, _uiObject);
                    }
                } while (stackOpenUIs.Count > 0);
            }
            yield return(0);
        }
예제 #2
0
 private void CloseUI(EnumUIType _uiType, GameObject _uiObj)
 {
     if (_uiObj == null)
     {
         dicOpenUIs.Remove(_uiType);
     }
     else
     {
         BaseUI _baseUI = _uiObj.GetComponent <BaseUI> ();
         if (_baseUI != null)
         {
             _baseUI.StateChanged += CloseUIHandler;
             _baseUI.Release();
         }
         else
         {
             GameObject.Destroy(_uiObj);
             dicOpenUIs.Remove(_uiType);
         }
     }
 }