Пример #1
0
        private void Awake()
        {
            UIFactory t = gameObject.GetComponent <UIFactory>();

            if (singletonObj == null)
            {
                singletonObj = gameObject;
                DontDestroyOnLoad(gameObject);
                singletonObj.name = typeof(UIFactory).FullName;
                instance          = t;
                OnInit();
                _applicationIsQuitting = false;
            }
            else if (singletonObj != gameObject)
            {
                MonoBehaviour[] monos = gameObject.GetComponents <MonoBehaviour>();
                if (monos.Length > 1)
                {
                    Destroy(t);
                }
                else
                {
                    Destroy(gameObject);
                }
            }
        }
        private UIBase LoadResUIBase(string uIFormName)
        {
            GameObject go = UIFactory.LoadUIPrefab(uIFormName);

            if (go == null)
            {
                Debug.LogError("预设是空的");
                return(null);
            }
            UIBase uiBase = go.GetComponent <UIBase>();

            if (uiBase != null)
            {
                uiBase.InitView();
                _dicAllUIForm[uIFormName] = uiBase;
                Debug.Log(uIFormName + "current:" + uiBase.m_uIFormName);

                UIFormSetParent(uiBase);
            }
            else
            {
                Debug.LogError("预设是空的");
            }
            return(uiBase);
        }
 void IHandleUIManager.InitView()
 {
     _stackUIForm  = new Stack <UIBase>();
     _dicCurUIForm = new Dictionary <string, UIBase>();
     _dicAllUIForm = new Dictionary <string, UIBase>();
     UIFactory.OnLoad();
     uIMaskMgr = new UIMaskMgr();
 }
Пример #4
0
        public void LoadLuaString(bool isAssetBundle, string dirType, string scriptName, string scriptPath)
        {
#if HOTFIX_ENABLE
            scriptEnv = UIManager.luaenv.NewTable();
            XLua.LuaTable meta = UIManager.luaenv.NewTable();
            meta.Set("__index", UIManager.luaenv.Global);
            scriptEnv.SetMetaTable(meta);
            meta.Dispose();
            scriptEnv.Set("self", this);

            if (dirType == "Resources")
            {
                TextAsset luaStr = Resources.Load <TextAsset>(scriptPath);
                if (luaStr != null)
                {
                    UIManager.luaenv.DoString(luaStr.text, "LuaUIBehaviour", scriptEnv);
                }
                else
                {
                    Debug.Log(scriptPath + "is null!");
                }
            }
            else if (dirType == "streamingAssetsPath")
            {
#if UNITY_ANDROID && !UNITY_EDITOR
                string str = UIFactory.GetAndoidStreamingAssetLuaScripts(scriptName);
                if (!string.IsNullOrEmpty(str))
                {
                    UIManager.luaenv.DoString(str, "LuaUIBehaviour", scriptEnv);
                }
                else
                {
                    Debug.Log(scriptPath + "is null!");
                }
#else
                LoadLuaScript(isAssetBundle, dirType, scriptName, scriptPath);
#endif
            }
            else
            {
                LoadLuaScript(isAssetBundle, dirType, scriptName, scriptPath);
            }

            scriptEnv.Get("uiFormType", out _luaUiFormType);
            scriptEnv.Get("OnInit", out luaOnInit);
            scriptEnv.Get("OnExcute", out luaOnExcute);
            scriptEnv.Get("OnDisplay", out luaOnDisplay);
            scriptEnv.Get("OnHide", out luaOnHide);
            scriptEnv.Get("OnReDisplay", out luaOnReDisplay);
            scriptEnv.Get("OnFreese", out luaOnFreese);
            scriptEnv.Get("OnRelease", out luaOnRelease);
#endif
        }
        private static void InitFactory()
        {
#if UNITY_ANDROID
            UIFactory.UNITY_Android = true;
#else
            UIFactory.UNITY_Android = false;
#endif

#if UNITY_EDITOR
            UIFactory.UNITY_Editor = true;
#else
            UIFactory.UNITY_Editor = false;
#endif
            UIFactory.OnLoad();
        }
 public void InitView()
 {
     if (Instance != null && Instance != this)
     {
         MonoBehaviour[] monos = gameObject.GetComponents <MonoBehaviour>();
         if (monos.Length > 1)
         {
             Destroy(this);
         }
         else
         {
             Destroy(gameObject);
         }
         return;
     }
     Instance = this;
     m_UIMgr  = UIFactory.CreateInternalUIManager();
     m_UIMgr.InitView();
 }
 private GameObject LoadUIMaskObj(string canvasName, Transform ParentObj)
 {
     if (dicMask.ContainsKey(canvasName))
     {
         return(dicMask[canvasName]);
     }
     else
     {
         GameObject GO = UIFactory.LoadUIMask();
         if (GO == null)
         {
             return(null);
         }
         GO.transform.SetParent(ParentObj);
         GO.transform.localPosition    = Vector3.zero;
         GO.transform.localEulerAngles = Vector3.zero;
         GO.transform.localScale       = Vector3.one;
         dicMask[canvasName]           = GO;
         return(GO);
     }
 }
Пример #8
0
        private void LoadLuaScript(bool isAssetBundle, string dirType, string scriptName, string scriptPath)
        {
            if (UIFactory.LoadString != null)
            {
                string content = (string)UIFactory.LoadString(scriptName);
                if (!string.IsNullOrEmpty(content))
                {
                    UIManager.luaenv.DoString(content, "LuaUIBehaviour", scriptEnv);
                }
                else
                {
                    Debug.Log(scriptName + "is null!");
                }
                return;
            }
            if (isAssetBundle)
            {
                TextAsset luaStr = UIFactory.LoadAssetBundleObj <TextAsset>(UIFactory.GetPath(dirType, scriptPath), scriptName);
                if (luaStr != null)
                {
                    UIManager.luaenv.DoString(luaStr.text, "LuaUIBehaviour", scriptEnv);
                }
                else
                {
                    Debug.Log(scriptPath + "is null!");
                }
            }
            else
            {
                string filePath = UIFactory.GetPath(dirType, scriptPath);
                string dir      = System.IO.Path.GetDirectoryName(filePath);
                string fl       = System.IO.Path.GetFileNameWithoutExtension(filePath);
                if (!System.IO.Directory.Exists(dir))
                {
                    Debug.LogError(dir + "is null");
                }

                string[] fls  = System.IO.Directory.GetFiles(dir);
                string   path = scriptPath;//完整路径
                for (int i = 0; i < fls.Length; i++)
                {
                    if (string.IsNullOrEmpty((fls[i])))
                    {
                        continue;
                    }
                    System.IO.FileInfo fs = new System.IO.FileInfo(fls[i]);
                    if (!fs.Exists)
                    {
                        continue;
                    }
                    if (fs.Extension == ".meta")
                    {
                        continue;
                    }
                    int findex = fs.Name.LastIndexOf(fl);
                    if (findex != 0)
                    {
                        continue;
                    }
                    path = fs.FullName;
                }
                Debug.Log(fl + ":" + path + ":" + fls.Length);
                string content = UIFactory.IOLoadFileStr(path);
                if (!string.IsNullOrEmpty(content))
                {
                    UIManager.luaenv.DoString(content, "LuaUIBehaviour", scriptEnv);
                }
                else
                {
                    Debug.Log(scriptPath + "is null!");
                }
            }
        }