示例#1
0
 public void Awake()
 {
     if (this.GetComponentInParent <ListNode>() is ListNode n)
     {
         node = n;
         Text t = (node.GetField <ListNode>("content") ?? node.GetField <ListNode>("textMesh")?.GetProperty("text")) as Text;
         t.resizeTextForBestFit = false;
         t.horizontalOverflow   = HorizontalWrapMode.Overflow;
         t.fontSize             = 13;
         t.alignment            = TextAnchor.MiddleCenter;
         Set(segmentLength, node.text);
     }
 }
示例#2
0
        public static void InitItemListPostfix(MonoBehaviour __instance)
        {
            Transform parent = __instance.GetField("transformRoot") as Transform;

            ListNode[] listNodes = parent.gameObject.GetComponentsInChildren <ListNode>();

            //Header
            if (__instance is ItemCategoryList && KK_StudioMenuScrollingText.HeaderDict.TryGetValue((int)__instance.GetField <ItemCategoryList>("group"), out string str))
            {
                makeFakeNode(str)?.transform.SetAsFirstSibling();
            }

            foreach (ListNode node in listNodes)
            {
                (node.gameObject.AddComponent(typeof(ScrollingTextComponent)) as ScrollingTextComponent).Set(13);
            }

            //Footer
            if (__instance is ItemCategoryList && KK_StudioMenuScrollingText.FooterDict.TryGetValue((int)__instance.GetField <ItemCategoryList>("group"), out str))
            {
                makeFakeNode(str)?.transform.SetAsLastSibling();
            }

            return;

            ListNode makeFakeNode(string s)
            {
                if (__instance is ItemCategoryList && null != __instance.GetField <ItemCategoryList>("group"))
                {
                    GameObject gameObject = UnityEngine.Object.Instantiate(__instance.GetField <ItemCategoryList>("objectPrefab") as GameObject);
                    if (!gameObject.activeSelf)
                    {
                        gameObject.SetActive(true);
                    }
                    gameObject.transform.SetParent(parent, false);
                    ListNode node = gameObject.GetComponent <ListNode>();

                    (node.gameObject.AddComponent(typeof(ScrollingTextComponent)) as ScrollingTextComponent).Set(13, s);
                    node.GetComponentInChildren <Button>().interactable = false;
                    Text t = (node.GetField <ListNode>("content") ?? node.GetField <ListNode>("textMesh")?.GetProperty("text")) as Text;
                    t.color = new Color(1, .64f, 0);
                    return(node);
                }
                return(null);
            }
        }