Beispiel #1
0
        private GameObject CreateButton(
            GameObject prefab,
            string name,
            UIAnchor anchor,
            UIPivot pivot,
            Vector2 offset,
            out ButtonInfo buttonInfo)
        {
            buttonInfo = (ButtonInfo)null;
            if (Object.op_Equality((Object)prefab, (Object)null))
            {
                return((GameObject)null);
            }
            GameObject gameObject = UITools.InstantiateGUIObject <ButtonInfo>(prefab, this.content.get_transform(), name, UIPivot.op_Implicit(pivot), (Vector2)anchor.min, (Vector2)anchor.max, offset);

            if (Object.op_Equality((Object)gameObject, (Object)null))
            {
                return((GameObject)null);
            }
            buttonInfo = (ButtonInfo)gameObject.GetComponent <ButtonInfo>();
            if (Object.op_Equality((Object)gameObject.GetComponent <Button>(), (Object)null))
            {
                Debug.Log((object)"Button prefab is missing Button component!");
                return((GameObject)null);
            }
            if (!Object.op_Equality((Object)buttonInfo, (Object)null))
            {
                return(gameObject);
            }
            Debug.Log((object)"Button prefab is missing ButtonInfo component!");
            return((GameObject)null);
        }
Beispiel #2
0
 private void CreateText(
     GameObject prefab,
     ref Text textComponent,
     string name,
     UIPivot pivot,
     UIAnchor anchor,
     Vector2 offset)
 {
     if (Object.op_Equality((Object)prefab, (Object)null) || Object.op_Equality((Object)this.content, (Object)null))
     {
         return;
     }
     if (Object.op_Inequality((Object)textComponent, (Object)null))
     {
         Debug.LogError((object)("Window already has " + name + "!"));
     }
     else
     {
         GameObject gameObject = UITools.InstantiateGUIObject <Text>(prefab, this.content.get_transform(), name, UIPivot.op_Implicit(pivot), (Vector2)anchor.min, (Vector2)anchor.max, offset);
         if (Object.op_Equality((Object)gameObject, (Object)null))
         {
             return;
         }
         textComponent = (Text)gameObject.GetComponent <Text>();
     }
 }
Beispiel #3
0
        public void AddContentText(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset)
        {
            Text textComponent = (Text)null;

            this.CreateText(prefab, ref textComponent, "Content Text", pivot, anchor, offset);
            this._contentText.Add(textComponent);
        }
Beispiel #4
0
        // Token: 0x060031E3 RID: 12771 RVA: 0x001468A8 File Offset: 0x00144AA8
        public void CreateButton(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset, string buttonText, UnityAction confirmCallback, UnityAction cancelCallback, bool setDefault)
        {
            if (prefab == null)
            {
                return;
            }
            ButtonInfo buttonInfo;
            GameObject gameObject = this.CreateButton(prefab, "Button", anchor, pivot, offset, out buttonInfo);

            if (gameObject == null)
            {
                return;
            }
            Button component = gameObject.GetComponent <Button>();

            if (confirmCallback != null)
            {
                component.onClick.AddListener(confirmCallback);
            }
            CustomButton customButton = component as CustomButton;

            if (cancelCallback != null && customButton != null)
            {
                customButton.CancelEvent += cancelCallback;
            }
            if (buttonInfo.text != null)
            {
                buttonInfo.text.text = buttonText;
            }
            if (setDefault)
            {
                this._defaultUIElement = gameObject;
            }
        }
Beispiel #5
0
        // Token: 0x060031DF RID: 12767 RVA: 0x00146878 File Offset: 0x00144A78
        public void AddContentText(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset)
        {
            Text item = null;

            this.CreateText(prefab, ref item, "Content Text", pivot, anchor, offset);
            this._contentText.Add(item);
        }
Beispiel #6
0
        public void AddContentText(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset)
        {
            Text text = null;

            CreateText(prefab, ref text, "Content Text", pivot, anchor, offset);
            _contentText.Add(text);
        }
Beispiel #7
0
 // Token: 0x060031EF RID: 12783 RVA: 0x00146A64 File Offset: 0x00144C64
 private void CreateImage(GameObject prefab, string name, UIPivot pivot, UIAnchor anchor, Vector2 offset)
 {
     if (!(prefab == null) && !(this.content == null))
     {
         UITools.InstantiateGUIObject <Image>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset);
         return;
     }
 }
Beispiel #8
0
 public void AddContentImage(
     GameObject prefab,
     UIPivot pivot,
     UIAnchor anchor,
     Vector2 offset,
     string text)
 {
     this.AddContentImage(prefab, pivot, anchor, offset);
 }
Beispiel #9
0
 public void AddContentText(
     GameObject prefab,
     UIPivot pivot,
     UIAnchor anchor,
     Vector2 offset,
     string text)
 {
     this.AddContentText(prefab, pivot, anchor, offset);
     this.SetContentText(text, this._contentText.Count - 1);
 }
Beispiel #10
0
        /// <summary>
        /// 设置 UI 组件枢轴
        /// </summary>
        /// <param name="rectTransform">UI 组件</param>
        /// <param name="x">X 轴锚点</param>
        /// <param name="y">Y 轴锚点</param>
        public static void SetUIPivot(RectTransform rectTransform, UIPivot pivot)
        {
            float x = 0.5f, y = 0.5f;

            switch (pivot)
            {
            case UIPivot.TopLeft:
                x = 0;
                y = 1;
                break;

            case UIPivot.TopCenter:
                x = 0.5f;
                y = 1;
                break;

            case UIPivot.TopRight:
                x = 1;
                y = 1;
                break;

            case UIPivot.CenterLeft:
                x = 0;
                y = 0.5f;
                break;

            case UIPivot.Center:
                x = 0.5f;
                y = 0.5f;
                break;

            case UIPivot.CenterRight:
                x = 1;
                y = 0.5f;
                break;

            case UIPivot.BottomCenter:
                x = 0.5f;
                y = 0;
                break;

            case UIPivot.BottomLeft:
                x = 0;
                y = 0;
                break;

            case UIPivot.BottomRight:
                x = 1;
                y = 0;
                break;
            }

            rectTransform.pivot = new Vector2(x, y);
        }
Beispiel #11
0
 private void CreateImage(
     GameObject prefab,
     string name,
     UIPivot pivot,
     UIAnchor anchor,
     Vector2 offset)
 {
     if (Object.op_Equality((Object)prefab, (Object)null) || Object.op_Equality((Object)this.content, (Object)null))
     {
         return;
     }
     UITools.InstantiateGUIObject <Image>(prefab, this.content.get_transform(), name, UIPivot.op_Implicit(pivot), (Vector2)anchor.min, (Vector2)anchor.max, offset);
 }
Beispiel #12
0
        public void CreateButton(
            GameObject prefab,
            UIPivot pivot,
            UIAnchor anchor,
            Vector2 offset,
            string buttonText,
            UnityAction confirmCallback,
            UnityAction cancelCallback,
            bool setDefault)
        {
            if (Object.op_Equality((Object)prefab, (Object)null))
            {
                return;
            }
            ButtonInfo buttonInfo;
            GameObject button = this.CreateButton(prefab, "Button", anchor, pivot, offset, out buttonInfo);

            if (Object.op_Equality((Object)button, (Object)null))
            {
                return;
            }
            Button component = (Button)button.GetComponent <Button>();

            if (confirmCallback != null)
            {
                ((UnityEvent)component.get_onClick()).AddListener(confirmCallback);
            }
            CustomButton customButton = component as CustomButton;

            if (cancelCallback != null && Object.op_Inequality((Object)customButton, (Object)null))
            {
                customButton.CancelEvent += cancelCallback;
            }
            if (Object.op_Inequality((Object)buttonInfo.text, (Object)null))
            {
                buttonInfo.text.set_text(buttonText);
            }
            if (!setDefault)
            {
                return;
            }
            this._defaultUIElement = button;
        }
Beispiel #13
0
        /// <summary>
        /// 获取 UI 组件枢轴
        /// </summary>
        /// <param name="rectTransform">UI 组件</param>
        public static UIPivot GetUIPivot(RectTransform rectTransform)
        {
            UIPivot uIPivot = UIPivot.None;
            float   x = rectTransform.pivot.x, y = rectTransform.pivot.y;

            if (x == 0 && y == 1)
            {
                uIPivot = UIPivot.TopLeft;
            }
            else if (x == 0 && y == 1)
            {
                uIPivot = UIPivot.TopCenter;
            }
            else if (x == 0.5f && y == 1)
            {
                uIPivot = UIPivot.TopRight;
            }
            else if (x == 1 && y == 1)
            {
                uIPivot = UIPivot.TopLeft;
            }
            else if (x == 0 && y == 1)
            {
                uIPivot = UIPivot.TopLeft;
            }
            else if (x == 0 && y == 1)
            {
                uIPivot = UIPivot.TopLeft;
            }
            else if (x == 0 && y == 1)
            {
                uIPivot = UIPivot.TopLeft;
            }
            else if (x == 0 && y == 1)
            {
                uIPivot = UIPivot.TopLeft;
            }

            return(uIPivot);
        }
Beispiel #14
0
        public void CreateButton(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset, string buttonText, UnityAction confirmCallback, UnityAction cancelCallback, bool setDefault)
        {
            if (prefab == null)
            {
                return;
            }
            ButtonInfo buttonInfo;
            GameObject instance = CreateButton(prefab, "Button", anchor, pivot, offset, out buttonInfo);

            if (instance == null)
            {
                return;
            }
            Button button = instance.GetComponent <Button>();

            if (confirmCallback != null)
            {
                button.onClick.AddListener(confirmCallback);
            }

            // Create a UI cancel event for this button
            CustomButton customButton = button as CustomButton;

            if (cancelCallback != null && customButton != null)
            {
                customButton.CancelEvent += cancelCallback;
            }

            if (buttonInfo.text != null)
            {
                buttonInfo.text.text = buttonText;
            }
            if (setDefault)
            {
                _defaultUIElement = instance;
            }
        }
Beispiel #15
0
        /// <summary>
        /// 设置 UI 组件枢轴
        /// </summary>
        /// <param name="rectTransform">UI 组件</param>
        public static void SetUIPivot(RectTransform rectTransform, UIPivot pivot, RectTransform.Axis axis)
        {
            float x = rectTransform.pivot.x, y = rectTransform.pivot.y;

            if (axis == RectTransform.Axis.Vertical)
            {
                if ((pivot & UIPivot.Top) == UIPivot.Top)
                {
                    y = 1;
                }
                else if ((pivot & UIPivot.Center) == UIPivot.Center)
                {
                    y = 0.5f;
                }
                else if ((pivot & UIPivot.Bottom) == UIPivot.Bottom)
                {
                    y = 0;
                }
            }
            else
            {
                if ((pivot & UIPivot.Left) == UIPivot.Left)
                {
                    x = 0;
                }
                else if ((pivot & UIPivot.Center) == UIPivot.Center)
                {
                    x = 0.5f;
                }
                else if ((pivot & UIPivot.Right) == UIPivot.Right)
                {
                    x = 1;
                }
            }

            rectTransform.pivot = new Vector2(x, y);
        }
Beispiel #16
0
 public void AddContentText(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset) {
     Text text = null;
     CreateText(prefab, ref text, "Content Text", pivot, anchor, offset);
     _contentText.Add(text);
 }
Beispiel #17
0
 public void CreateButton(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset, string buttonText, UnityAction confirmCallback, UnityAction cancelCallback, bool setDefault)
 {
     if (prefab == null)
     {
         return;
     }
     ButtonInfo buttonInfo;
     GameObject gameObject = this.CreateButton(prefab, "Button", anchor, pivot, offset, out buttonInfo);
     if (gameObject == null)
     {
         return;
     }
     UnityEngine.UI.Button component = gameObject.GetComponent<UnityEngine.UI.Button>();
     if (confirmCallback != null)
     {
         component.onClick.AddListener(confirmCallback);
     }
     CustomButton customButton = component as CustomButton;
     if (cancelCallback != null && customButton != null)
     {
         customButton.CancelEvent += cancelCallback;
     }
     if (buttonInfo.text != null)
     {
         buttonInfo.text.text = buttonText;
     }
     if (setDefault)
     {
         this._defaultUIElement = gameObject;
     }
 }
Beispiel #18
0
 public static bool AlignHCenter(UIPivot pivot)
 {
     return(pivot == UIPivot.Center || pivot == UIPivot.Top || pivot == UIPivot.Bottom);
 }
Beispiel #19
0
        // Private Methods

        private void CreateText(GameObject prefab, ref Text textComponent, string name, UIPivot pivot, UIAnchor anchor, Vector2 offset) {
            if(prefab == null || content == null) return;
            if(textComponent != null) {
                Debug.LogError("Window already has " + name + "!");
                return;
            }

            GameObject instance = UITools.InstantiateGUIObject<Text>(
                prefab,
                content.transform,
                name,
                pivot,
                anchor.min,
                anchor.max,
                offset
            );
            if(instance == null) return;
            textComponent = instance.GetComponent<Text>();
        }
Beispiel #20
0
        private GameObject CreateButton(GameObject prefab, string name, UIAnchor anchor, UIPivot pivot, Vector2 offset, out ButtonInfo buttonInfo) {
            buttonInfo = null;
            if(prefab == null) return null;
            
            GameObject instance = UITools.InstantiateGUIObject<ButtonInfo>(
                prefab,
                content.transform,
                name,
                pivot,
                anchor.min,
                anchor.max,
                offset
            );
            if(instance == null) return null;

            buttonInfo = instance.GetComponent<ButtonInfo>();
            Button button = instance.GetComponent<Button>();
            if(button == null) {
                Debug.Log("Button prefab is missing Button component!");
                return null;
            }
            if(buttonInfo == null) {
                Debug.Log("Button prefab is missing ButtonInfo component!");
                return null;
            }
            return instance;
        }
Beispiel #21
0
    /// <summary>
    /// 动态创建Toggle,包括动态绑定按钮方法
    /// </summary>
    /// <param name="togglesText"></param>
    /// <param name="gridList"></param>
    public static GameObject CreateToggleDynamic(string[] togglesText, UIPivot pivot, ToggleType type, string npcName)
    {
        int length = togglesText.Length;

        if (length < 2)
        {
            Debug.Log("不需要创建Toggle");
            return(null);
        }
        //根据不同的选项个数创建不同长度的toggle
        float toggleHeight = length * 90 - 20;

        GameObject go = Resources.Load <GameObject>(Consts.PrefabUIDir + "Toggle");

        toggleGo = GameObject.Instantiate(go);
        toggleGo.transform.SetParent(CanvasTrans, false);
        toggleGo.transform.localScale = new Vector3(1, 1, 1);
        toggleGo.name = "Toggle";
        RectTransform rect = toggleGo.GetComponent <RectTransform>();

        rect.sizeDelta = new Vector2(200, toggleHeight);

        Vector3 initPos = Vector3.zero;

        //选择创建的位置
        switch (pivot)
        {
        case UIPivot.Middle:
            initPos        = new Vector3(0, 0, 0);
            rect.anchorMin = new Vector2(0.5f, 0.5f);
            rect.anchorMax = new Vector2(0.5f, 0.5f);
            break;

        case UIPivot.RightDown:
            initPos        = new Vector3(-190, 130, 0);
            rect.anchorMin = new Vector2(1, 0);
            rect.anchorMax = new Vector2(1, 0);
            break;
        }

        toggleGo.GetComponent <RectTransform>().localPosition = initPos;

        for (int i = 0; i < togglesText.Length; i++)
        {
            go = Resources.Load <GameObject>(Consts.PrefabUIDir + "ToggleGrid");

            GameObject gridGo = GameObject.Instantiate(go);

            gridGo.transform.SetParent(toggleGo.transform, false);
            gridGo.transform.name = i.ToString();
            gridGo.GetComponentInChildren <Text>().text = togglesText[i];

            if (i == 0)
            {
                //选项默认第一个高亮
                EventSystem.current.SetSelectedGameObject(gridGo);
            }

            //添加事件响应
            string gridName = gridGo.GetComponentInChildren <Text>().text;

            switch (type)
            {
            case ToggleType.ToggleCommand:
                //角色对话时的响应事件
                gridGo.GetComponent <Button>().onClick.AddListener(delegate()
                {
                    StoryManager.Instance.OnToggleCommandClick(gridName, npcName, true);
                });
                break;

            case ToggleType.BackgroundTab:
                //起始选择角色背景的Toggle
                gridGo.GetComponent <Button>().onClick.AddListener(delegate()
                {
                    StoryManager.Instance.OnBackgroundTabClick(gridName);
                });
                break;

            case ToggleType.Backpack:
                //背包里的Toggle,使用或取消
                BackpackToggle bt = toggleGo.AddComponent <BackpackToggle>();

                gridGo.GetComponent <Button>().onClick.AddListener(delegate()
                {
                    bt.UseItemDeal(gridName);
                });
                break;
            }
        }

        toggleGo.SetActive(true);

        return(toggleGo);
    }
Beispiel #22
0
 public void AddContentImage(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset, string text) {
     AddContentImage(prefab, pivot, anchor, offset);
 }
Beispiel #23
0
        // Private Methods

        private void CreateText(GameObject prefab, ref Text textComponent, string name, UIPivot pivot, UIAnchor anchor, Vector2 offset)
        {
            if (prefab == null || content == null)
            {
                return;
            }
            if (textComponent != null)
            {
                Debug.LogError("Window already has " + name + "!");
                return;
            }

            GameObject instance = UITools.InstantiateGUIObject <Text>(
                prefab,
                content.transform,
                name,
                pivot,
                anchor.min,
                anchor.max,
                offset
                );

            if (instance == null)
            {
                return;
            }
            textComponent = instance.GetComponent <Text>();
        }
Beispiel #24
0
 public void AddContentText(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset, string text)
 {
     this.AddContentText(prefab, pivot, anchor, offset);
     this.SetContentText(text, this._contentText.Count - 1);
 }
Beispiel #25
0
 public void AddContentImage(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset)
 {
     CreateImage(prefab, "Image", pivot, anchor, offset);
 }
Beispiel #26
0
 public static bool AlignLeft(UIPivot pivot)
 {
     return(pivot == UIPivot.Left || pivot == UIPivot.TopLeft || pivot == UIPivot.BottomLeft);
 }
Beispiel #27
0
 public static bool AlignVCenter(UIPivot pivot)
 {
     return(pivot == UIPivot.Center || pivot == UIPivot.Left || pivot == UIPivot.Right);
 }
Beispiel #28
0
 public void AddContentText(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset, string text) {
     AddContentText(prefab, pivot, anchor, offset);
     SetContentText(text, _contentText.Count - 1);
 }
Beispiel #29
0
        private GameObject CreateButton(GameObject prefab, string name, Rewired.UI.UIAnchor anchor, UIPivot pivot, Vector2 offset, out ButtonInfo buttonInfo)
        {
            buttonInfo = null;
            if (prefab == null)
            {
                return(null);
            }
            GameObject gameObject = UITools.InstantiateGUIObject <ButtonInfo>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset);

            if (gameObject == null)
            {
                return(null);
            }
            buttonInfo = gameObject.GetComponent <ButtonInfo>();
            UnityEngine.UI.Button component = gameObject.GetComponent <UnityEngine.UI.Button>();
            if (component == null)
            {
                UnityEngine.Debug.Log("Button prefab is missing Button component!");
                return(null);
            }
            if (buttonInfo == null)
            {
                UnityEngine.Debug.Log("Button prefab is missing ButtonInfo component!");
                return(null);
            }
            return(gameObject);
        }
Beispiel #30
0
 public void AddContentImage(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset) {
     CreateImage(prefab, "Image", pivot, anchor, offset);
 }
Beispiel #31
0
        private void CreateText(GameObject prefab, ref Text textComponent, string name, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset)
        {
            if (prefab == null || this.content == null)
            {
                return;
            }
            if (textComponent != null)
            {
                UnityEngine.Debug.LogError("Window already has " + name + "!");
                return;
            }
            GameObject gameObject = UITools.InstantiateGUIObject <Text>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset);

            if (gameObject == null)
            {
                return;
            }
            textComponent = gameObject.GetComponent <Text>();
        }
Beispiel #32
0
        public void CreateButton(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset, string buttonText, UnityAction confirmCallback, UnityAction cancelCallback, bool setDefault) {
            if(prefab == null) return;
            ButtonInfo buttonInfo;
            GameObject instance = CreateButton(prefab, "Button", anchor, pivot, offset, out buttonInfo);
            if(instance == null) return;
            Button button = instance.GetComponent<Button>();
            if(confirmCallback != null) button.onClick.AddListener(confirmCallback);

            // Create a UI cancel event for this button
            CustomButton customButton = button as CustomButton;
            if(cancelCallback != null && customButton != null) customButton.CancelEvent += cancelCallback;

            if(buttonInfo.text != null) buttonInfo.text.text = buttonText;
            if(setDefault) _defaultUIElement = instance;
        }
Beispiel #33
0
 private void CreateText(GameObject prefab, ref Text textComponent, string name, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset)
 {
     if (prefab == null || this.content == null)
     {
         return;
     }
     if (textComponent != null)
     {
         UnityEngine.Debug.LogError("Window already has " + name + "!");
         return;
     }
     GameObject gameObject = UITools.InstantiateGUIObject<Text>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset);
     if (gameObject == null)
     {
         return;
     }
     textComponent = gameObject.GetComponent<Text>();
 }
Beispiel #34
0
        private void CreateImage(GameObject prefab, string name, UIPivot pivot, UIAnchor anchor, Vector2 offset) {
            if(prefab == null || content == null) return;

            UITools.InstantiateGUIObject<Image>(
                prefab,
                content.transform,
                name,
                pivot,
                anchor.min,
                anchor.max,
                offset
            );
        }
Beispiel #35
0
 private GameObject CreateButton(GameObject prefab, string name, Rewired.UI.UIAnchor anchor, UIPivot pivot, Vector2 offset, out ButtonInfo buttonInfo)
 {
     buttonInfo = null;
     if (prefab == null)
     {
         return null;
     }
     GameObject gameObject = UITools.InstantiateGUIObject<ButtonInfo>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset);
     if (gameObject == null)
     {
         return null;
     }
     buttonInfo = gameObject.GetComponent<ButtonInfo>();
     UnityEngine.UI.Button component = gameObject.GetComponent<UnityEngine.UI.Button>();
     if (component == null)
     {
         UnityEngine.Debug.Log("Button prefab is missing Button component!");
         return null;
     }
     if (buttonInfo == null)
     {
         UnityEngine.Debug.Log("Button prefab is missing ButtonInfo component!");
         return null;
     }
     return gameObject;
 }
Beispiel #36
0
 public static bool AlignRight(UIPivot pivot)
 {
     return(pivot == UIPivot.Right || pivot == UIPivot.TopRight || pivot == UIPivot.BottomRight);
 }
Beispiel #37
0
 public void CreateTitleText(GameObject prefab, Vector2 offset)
 {
     this.CreateText(prefab, ref this._titleText, "Title Text", UIPivot.get_TopCenter(), UIAnchor.get_TopHStretch(), offset);
 }
Beispiel #38
0
 public static bool AlignTop(UIPivot pivot)
 {
     return(pivot == UIPivot.Top || pivot == UIPivot.TopLeft || pivot == UIPivot.TopRight);
 }
Beispiel #39
0
 public static bool AlignBottom(UIPivot pivot)
 {
     return(pivot == UIPivot.Bottom || pivot == UIPivot.BottomLeft || pivot == UIPivot.BottomRight);
 }
Beispiel #40
0
        private GameObject CreateButton(GameObject prefab, string name, UIAnchor anchor, UIPivot pivot, Vector2 offset, out ButtonInfo buttonInfo)
        {
            buttonInfo = null;
            if (prefab == null)
            {
                return(null);
            }

            GameObject instance = UITools.InstantiateGUIObject <ButtonInfo>(
                prefab,
                content.transform,
                name,
                pivot,
                anchor.min,
                anchor.max,
                offset
                );

            if (instance == null)
            {
                return(null);
            }

            buttonInfo = instance.GetComponent <ButtonInfo>();
            Button button = instance.GetComponent <Button>();

            if (button == null)
            {
                Debug.Log("Button prefab is missing Button component!");
                return(null);
            }
            if (buttonInfo == null)
            {
                Debug.Log("Button prefab is missing ButtonInfo component!");
                return(null);
            }
            return(instance);
        }
Beispiel #41
0
 public void AddContentText(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset)
 {
     Text item = null;
     this.CreateText(prefab, ref item, "Content Text", pivot, anchor, offset);
     this._contentText.Add(item);
 }