Ejemplo n.º 1
0
        public void AddCustomDebugToolItem(string text, GameHandler callbackHandler)
        {
            GameObject    newGo         = GameCloneUtils.CreateEmptyUIObjectWithParent(DebugToolsItemHost.transform, "DebugToolItem");
            RectTransform rectTransform = newGo.GetComponent <RectTransform>();

            rectTransform.pivot = new Vector2(0, 1);
            UIAnchorPosUtils.SetUIAnchor(rectTransform, UIAnchor.Stretch, UIAnchor.Top);

            CustomData customData = newGo.AddComponent <CustomData> ();

            customData.customData = callbackHandler;
            Text newText = newGo.AddComponent <Text>();

            newText.font      = Resources.GetBuiltinResource <Font>("Arial.ttf");
            newText.text      = text;
            newText.color     = Color.white;
            newText.fontSize  = 11;
            newText.alignment = TextAnchor.MiddleCenter;
            ContentSizeFitter contentSizeFitter = newGo.AddComponent <ContentSizeFitter>();

            contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;

            EventTriggerListener.Get(newGo).onClick = OnCustomDebugToolItemClick;
            rectTransform.anchoredPosition          = new Vector2(rectTransform.anchoredPosition.x, -customDebugToolItemY);
            customDebugToolItemY        += 20;
            DebugToolsItemHost.sizeDelta = new Vector2(DebugToolsItemHost.sizeDelta.x, customDebugToolItemY);
        }