示例#1
0
        public static T GetILRComponent <T>(this UIControllerILR ilr) where T : Component
        {
            T ilinstance = ilr.ilinstance as T;

            if (ilinstance == null)
            {
                ilr.ILRObjInit();
                ilinstance = ilr.ilinstance as T;
            }
            return(ilinstance);
        }
示例#2
0
        bool CheckPloaded(PrefabCreator[] pcs, PrefabLoader[] loaders, PloadData data)
        {
            bool isPloaded = true;

            for (int i = 0; i < pcs.Length; i++)
            {
                if (!pcs[i].isCurrendAssetLoaded)
                {
                    isPloaded = false;
                    break;
                }
            }

            if (isPloaded)
            {
                for (int i = 0; i < loaders.Length; i++)
                {
                    if (!loaders[i].IsAssetLoaded)
                    {
                        isPloaded = false;
                        break;
                    }
                }
            }

            if (isPloaded)
            {
                if (m_IsPloadedHandler != 0)
                {
                    ILRTimerManager.instance.RemoveTimer(m_IsPloadedHandler);
                    m_IsPloadedHandler = 0;
                }

                if (data.IsHotfix)
                {
                    if (data.Go.GetComponent <UIControllerILR>() == null)
                    {
                        UIControllerILR ucr = data.Go.AddComponent <UIControllerILR>();
                        ucr.hotfixClassPath = hotfixClassPath;
                        ucr.ILRObjInit();
                    }
                    else
                    {
                        UIControllerILR ucr = data.Go.GetComponent <UIControllerILR>();
                        ucr.ILRObjInit();
                    }
                }

                OnAssetProcess(data.AssetName, data.Go);
            }
            return(isPloaded);
        }
示例#3
0
        public override void Awake()
        {
            base.Awake();

            var t = mDMono.transform;

            _controllerILR = t.GetComponentInParent <UIControllerILR>();
            Transform store_root = _controllerILR.transform;

            m_Scroll         = store_root.GetMonoILRComponent <UIStoreGridScroll>("Store/NewBlacksmithView/BlacksmithViews/Shared/SlotsContainer/Placeholder/Grid");
            m_GetDataRequest = t.GetComponent <UIServerRequest>("Extra/Get");
            m_RefreshRequest = t.GetComponent <UIServerRequest>("Extra/Refresh");
            m_BuyRequest     = store_root.GetComponent <UIServerRequest>("Store/NewBlacksmithView/BlacksmithViews/Shared/Extra/Buy");

            RefreshBtnRoot          = store_root.GetComponent <UIButton>("Store/BGs/Bottom/Button", false);
            RefreshCostLabel        = store_root.GetComponent <UILabel>("Store/BGs/Bottom/Button/Cost/Diamand/Label", false);
            m_RefreshTimeLabel      = store_root.GetComponent <UILabel>("Store/BGs/Bottom/RefreshTime", false);
            RefreshCostSprite       = store_root.GetComponent <UISprite>("Store/BGs/Bottom/Button/Cost/Diamand/Sprite", false);
            NewCurrencyCommonLabel  = store_root.GetComponent <UILabel>("UINormalFrameBG/NewCurrency/Table/1_Common/Label");
            NewCurrencyCommonSprite = store_root.GetComponent <UISprite>("UINormalFrameBG/NewCurrency/Table/1_Common/Icon");
            RefreshFxObj            = store_root.FindEx("Store/NewBlacksmithView/BlacksmithViews/Shared/Fx").gameObject;

            UIServerRequestHotFix mysGetRequest = t.GetMonoILRComponent <UIServerRequestHotFix>("Extra/Get");

            mysGetRequest.response = OnRequestStoreData;
            t.GetComponent <UIServerRequest>("Extra/Get").onResponse.Add(new EventDelegate(mysGetRequest.mDMono, "OnFetchData"));

            UIServerRequestHotFix mysRefreshRequest = t.GetMonoILRComponent <UIServerRequestHotFix>("Extra/Refresh");

            mysRefreshRequest.response = OnRefresh;
            t.GetComponent <UIServerRequest>("Extra/Refresh").onResponse.Add(new EventDelegate(mysRefreshRequest.mDMono, "OnFetchData"));

            UIServerRequestHotFix buyRequest = t.parent.GetMonoILRComponent <UIServerRequestHotFix>("Shared/Extra/Buy");

            if (buyRequest.response == null)
            {
                buyRequest.response = OnBuy;
                t.parent.GetComponent <UIServerRequest>("Shared/Extra/Buy").onResponse.Add(new EventDelegate(buyRequest.mDMono, "OnFetchData"));
            }

            m_DataID    = mDMono.StringParamList[0];
            m_StoreType = mDMono.StringParamList[1];
            m_StoreName = mDMono.StringParamList[2];
            m_StoreId   = mDMono.IntParamList[0];
            m_Columns   = mDMono.IntParamList[1];

            CronRefreshExcuter re = CreateShopRefresher();

            AutoRefreshingManager.Instance.AddCronRefreshExcuter(re);
        }
示例#4
0
        private void OnClickStart()
        {
            List <TeamMemberData> list = LTFormationDataManager.Instance.GetTeamMemList("lt_st");

            if (list.Count == 0)
            {
                MessageTemplateManager.ShowMessage(eMessageUIType.FloatingText, EB.Localizer.GetString("ID_guide_words_902314_context"));
                return;
            }
            if (m_OnClickChallenge != null)
            {
                UIControllerILR          uiController = GlobalMenuManager.Instance.GetMenu <UIControllerILR>("LTCombatReadyUI");
                BattleReadyHudController controller   = uiController.ilinstance as BattleReadyHudController;
                if (controller != null)
                {
                    controller.mStartBattleClick = true;
                }
                m_OnClickChallenge(m_Data.layer, diffculty, (re) =>
                {
                    DataLookupsCache.Instance.CacheData(re);
                });
            }
        }
示例#5
0
    public static void AutoTrimAndReplace()
    {
        UIControllerILR current = UnityEditor.Selection.activeGameObject.GetComponent <UIControllerILR>();

        if (!string.IsNullOrEmpty(current.hotfixClassPath))
        {
            TextAsset script = AssetDatabase.LoadAssetAtPath <TextAsset>(string.Concat("Assets/", current.FilePath));
            if (script == null || script.text == String.Empty)
            {
                Debug.LogError("Could not read text by " + string.Concat("Assets/", current.FilePath));
                return;
            }

            string[]      rows      = script.text.Split(new string[] { "\n" }, StringSplitOptions.None);
            List <string> writeRows = new List <string>();

            current.ParmPathList.ForEach(p =>
            {
                // 删掉字段声明
                // ------------------------------------
                int rowIndex = -1;
                for (int i = 0; i < rows.Length; i++)
                {
                    string row = rows[i];
                    if (row.Contains(p.Type + " " + p.Name))
                    {
                        rowIndex = i;
                        break;
                    }
                }

                if (rowIndex >= 0)
                {
                    rows[rowIndex] = string.Empty;
                }
                // ------------------------------------

                // 删掉初始化
                // Field = t.Get, Field = t.Find -----
                int rowIndex2 = -1;
                for (int i = 0; i < rows.Length; i++)
                {
                    string row = rows[i];
                    if (row.Contains(p.Name + " = t.Get") || row.Contains(p.Name + " = t.Find") || row.Contains(p.Name + " = controller.transform.Find") ||
                        row.Contains(p.Name + " = controller.transform.Get"))
                    {
                        rowIndex2 = i;
                        break;
                    }
                }
                if (rowIndex2 >= 0)
                {
                    rows[rowIndex2] = string.Empty;
                }

                //List创建绑定无法自动分析,无法得知用到的List,因为这个方法没有反射,父类没有记录

                // 替换代码中用到的行
                for (int i = 0; i < rows.Length; i++)
                {
                    string row = rows[i];
                    if (i != rowIndex && i != rowIndex2 && !row.Contains("/" + p.Name) && !row.Contains(p.Name + "/"))
                    {
                        string typeName      = p.Type == UIControllerILR.ParmType.GameObject ? "GObject" : p.Type.ToString();
                        typeName             = p.Type == UIControllerILR.ParmType.CampaignTextureCmp ? "TextureCmp" : typeName;
                        typeName             = p.Type == UIControllerILR.ParmType.ConsecutiveClickCoolTrigger ? "CoolTrigger" : typeName;
                        string containerName = typeName.Contains("UI") ? p.Type.ToString().Replace("UI", "Ui") + "s" : typeName.ToString() + "s";
                        rows[i] = rows[i].ReplaceWholeWord(p.Name, string.Concat("controller.", containerName, string.Format("[\"{0}\"]", p.Name)));
                    }
                }
            });

            for (int i = 0; i < rows.Length; i++)
            {
                if (string.IsNullOrEmpty(rows[i]))
                {
                    continue;
                }
                writeRows.Add(rows[i].Replace("\r", string.Empty));
            }

            string writePath = string.Concat(Application.dataPath, "/", current.FilePath);
            File.WriteAllLines(writePath, writeRows.ToArray());

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
    }
示例#6
0
    public static void AutoBinding()
    {
#if !ILRuntime
        UIControllerILR current = UnityEditor.Selection.activeGameObject.GetComponent <UIControllerILR>();

        UIControllerILRObject instance = current.ilinstance;
        bool release = false;
        if (!string.IsNullOrEmpty(current.hotfixClassPath))
        {
            var type = HotfixILRManager.GetInstance().assembly.GetType(current.hotfixClassPath);
            if (instance == null)
            {
                instance = System.Activator.CreateInstance(type) as UIControllerILRObject;
                release  = true;
            }

            FieldInfo[] fields = type.GetFields();
            TextAsset   script = AssetDatabase.LoadAssetAtPath <TextAsset>(string.Concat("Assets/", current.FilePath));
            if (script == null || script.text == String.Empty)
            {
                Debug.LogError("Could not read text by " + string.Concat("Assets/", current.FilePath));
                return;
            }

            string[] rows      = script.text.Split(new string[] { "\n" }, StringSplitOptions.None);
            string   targetRow = string.Empty;

            foreach (FieldInfo f in fields)
            {
                System.Type fieldType = f.FieldType;
                Debug.LogFormat("field.Name = {0},field.Type.Name = {1}", f.Name, fieldType.Name);
                UIControllerILR.ParmType fieldEnumType;
                if (System.Enum.TryParse(fieldType.Name, out fieldEnumType))
                {
                    if (!current.ParmPathList.Exists(p => p.Name == f.Name))
                    {
                        UIControllerILR.ParmStruct structural = new UIControllerILR.ParmStruct();
                        structural.Name = f.Name;
                        structural.Type = fieldEnumType;

                        for (int i = 0; i < rows.Length; i++)
                        {
                            string row = rows[i];
                            if (row.Contains(f.Name + " = t.") || row.Contains(f.Name + " = controller.transform."))
                            {
                                targetRow = row;
                                break;
                            }
                        }
                        if (string.IsNullOrEmpty(targetRow))
                        {
                            Debug.Log("<color=yellow>this filed has not found or got by awake method!</color>"); continue;
                        }

                        string[] parts = targetRow.TrimAll('"').Split('(');
                        if (parts.Length > 1)
                        {
                            string text = parts[1].TrimAll('(', ')', ';', '.').Replace("gameObject", String.Empty).TrimEnd();
                            if (!string.IsNullOrEmpty(text))
                            {
                                structural.Path = text.Replace(String.Format("GetComponent<{0}>", structural.Type.ToString()), "");
                            }
                            Debug.LogFormat("Create ParmStruct: <color=purple>Name = {0},Type = {1},Path = {2}</color>", structural.Name, structural.Type, structural.Path);
                        }

                        current.ParmPathList.Add(structural);
                        EditorUtility.SetDirty(current);
                    }
                }
                else
                {
                    Debug.Log("<color=red>field type is not feasible!</color>");
                }
            }
        }

        if (release)
        {
            instance = null;
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
#else
        EB.Debug.LogError("ILR模式下不存在assembly,会报错!请自行解决后再去掉这个宏。");
#endif
    }
示例#7
0
 public override void SetUIController(UIControllerILR uicontroller) {
     controller = uicontroller;
 }
示例#8
0
        /// <summary>
        /// 对加载预制完成的数据进行处理(热更的处理,预制嵌套的处理等)
        /// </summary>
        /// <param name="isHotfix"></param>
        /// <param name="assetName"></param>
        /// <param name="go"></param>
        /// <returns></returns>
        IEnumerator Process(bool isHotfix, string assetName, GameObject go)
        {
            if (isHotfix)
            {
                while (!HotfixILRManager.GetInstance().IsInit)
                {
                    yield return(null);
                }
            }

            PrefabCreator[] pcs = go.GetComponentsInChildren <PrefabCreator>(true);
            for (int i = 0; i < pcs.Length; i++)
            {
                pcs[i].LoadAsset();
            }

            PrefabLoader[] loaders = go.GetComponentsInChildren <PrefabLoader>(true);
            for (int i = 0; i < loaders.Length; i++)
            {
                loaders[i].LoadPrefab();
            }

            bool isPloaded = false;

            while (!isPloaded)
            {
                isPloaded = true;
                for (int i = 0; i < pcs.Length; i++)
                {
                    if (!pcs[i].isCurrendAssetLoaded)
                    {
                        isPloaded = false;
                        break;
                    }
                }
                if (!isPloaded)
                {
                    yield return(null);
                }
            }

            bool isLoaded = false;

            while (!isLoaded)
            {
                isLoaded = true;
                for (int i = 0; i < loaders.Length; i++)
                {
                    if (!loaders[i].IsAssetLoaded)
                    {
                        isLoaded = false;
                        break;
                    }
                }
                if (!isLoaded)
                {
                    yield return(null);
                }
            }

            if (isHotfix)
            {
                if (go.GetComponent <UIControllerILR>() == null)
                {
                    UIControllerILR ucr = go.AddComponent <UIControllerILR>();
                    ucr.hotfixClassPath = hotfixClassPath;
                    ucr.ILRObjInit();
                }
                else
                {
                    UIControllerILR ucr = go.GetComponent <UIControllerILR>();
                    ucr.ILRObjInit();
                }
            }

            OnAssetProcess(assetName, go);
        }
示例#9
0
 public virtual void SetUIController(UIControllerILR uicontroller)
 {
 }