Exemple #1
0
        private static void ConfigAddFix(ConfigScene __instance, ref IEnumerator __result)
        {
            BaseSetting setting = null;

            __result = __result
                       .AppendCo(new WaitForEndOfFrame())
                       .AppendCo(() =>
            {
                try
                {
                    var add = __instance.transform.Find("Canvas/imgWindow/ScrollView/Content/Node Addtional");

                    if (add && add.gameObject.activeInHierarchy)
                    {
                        var add20Prop = Traverse.Create <Game>().Property("isAdd20");
                        if (add20Prop.FieldExists() && add20Prop.GetValue <bool>())
                        {
                            var add20Tr = __instance.transform.Find("Canvas/imgWindow/ScrollView/Content/Node Addtional_20");
                            if (add20Tr)
                            {
                                add20Tr.gameObject.SetActive(true);
                                add20Tr.SetSiblingIndex(add.GetSiblingIndex());
                                setting = add20Tr.GetComponent <BaseSetting>();
                                add.gameObject.SetActive(false);
                            }
                        }
                        else
                        {
                            var addNormalTr = __instance.transform.Find("Canvas/imgWindow/ScrollView/Content/Node Addtional_normal");
                            if (addNormalTr)
                            {
                                addNormalTr.gameObject.SetActive(true);
                                addNormalTr.SetSiblingIndex(add.GetSiblingIndex());
                                setting = addNormalTr.GetComponent <BaseSetting>();
                                add.gameObject.SetActive(false);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    UnityEngine.Debug.LogException(e);
                }
            })
                       .AppendCo(new WaitForEndOfFrame())
                       .AppendCo(() =>
            {
                if (setting != null)
                {
                    // Need to wait until next frame to init because mobcolor setting will be corrupted if inited before colorpicker Start runs
                    setting.Init();
                    setting.UIPresenter();
                }
            });
        }