示例#1
0
        public ButtonWidget()
        {
            root = new ElementRoot();

            var buttonGO    = new GameObject("Button");
            var buttonRect  = buttonGO.AddComponent <RectTransform>();
            var buttonImage = buttonGO.AddComponent <Image>();

            buttonImage.sprite = uFrame.configuration.body;
            buttonImage.type   = Image.Type.Sliced;

            root.transform = buttonRect;

            buttonImage.color               = Color.gray;
            button                          = buttonGO.AddComponent <Button>();
            button.targetGraphic            = buttonImage;
            root.transform.sizeDelta        = new Vector2(120, 40);
            root.transform.anchoredPosition = Vector2.zero;

            var titleGO = new GameObject("Title Text");

            titleGO.transform.SetParent(root.transform);

            buttonTitleRect           = titleGO.AddComponent <RectTransform>();
            buttonTitleRect.anchorMin = Vector2.zero;      //set anchor min max to be able to stretch
            buttonTitleRect.anchorMax = Vector2.one;
            buttonTitleRect.Right(0f);                     //set manually full stretch
            buttonTitleRect.Left(0f);
            buttonTitleRect.Bottom(0f);
            buttonTitleRect.Top(0f);
            buttonTitleText           = titleGO.AddComponent <Text>();
            buttonTitleText.font      = uFrame.configuration.defaultFont;
            buttonTitleText.alignment = TextAnchor.MiddleCenter;
        }
示例#2
0
        /// <summary>
        /// <see cref="ElementRoot"/>を登録します。
        /// </summary>
        /// <remarks>
        /// この<see cref="BoxUIRootNode"/>に登録するための新規<see cref="Element"/>のCreateを行う前に、<see cref="ClearElement()"/>メソッドを呼び出してください。
        /// <see cref="BoxUIRootNode"/>の更新中(例えばボタンのクリック時など)に呼び出したい場合は、<see cref="BoxUISystem.Post(Action)"/>を利用して、メソッドの呼び出しを遅延してください。
        /// </remarks>
        /// <exception cref="InvalidOperationException"></exception>
        public void SetElement(ElementRoot elementRoot)
        {
            if (isUpdating_)
            {
                throw new InvalidOperationException("このBoxUIRootNodeの更新中にElementを更新することはできません。");
            }

            if (elementRoot.Root is { })
示例#3
0
    public TextWidget()
    {
        root = new ElementRoot();

        var titleGO  = new GameObject("Title Text");
        var textRect = titleGO.AddComponent <RectTransform>();

        root.transform                  = textRect;
        root.transform.sizeDelta        = new Vector2(100, 30);
        root.transform.anchoredPosition = Vector2.zero;

        titleGO.transform.SetParent(root.transform);
        text           = titleGO.AddComponent <Text>();
        text.font      = Resources.GetBuiltinResource <Font>("Arial.ttf");
        text.alignment = TextAnchor.MiddleCenter;
        text.color     = Color.black;
    }
示例#4
0
    public HBoxWidget()
    {
        root = new ElementRoot();

        var boxGO   = new GameObject("HBox");
        var boxRect = boxGO.AddComponent <RectTransform>();

        root.transform = boxRect;

        background       = boxGO.AddComponent <Image>();
        background.color = Color.white;

        layout = boxGO.AddComponent <HorizontalLayoutGroup>();
        layout.childControlHeight     = false;
        layout.childControlWidth      = false;
        layout.childForceExpandHeight = false;
        layout.childForceExpandWidth  = false;
        layout.SetLayoutHorizontal();
    }
        private void GenerateDisplayElements()
        {
            // Element Root

            var elementRootGo = new GameObject("|| RECT TRANSFORM DEBUGGER ||");

            ElementRoot = elementRootGo.AddComponent <RectTransform>();

            ElementRoot.SetParent(DebugRectTransform, false);
            ElementRoot.sizeDelta = new Vector2(0.0f, 0.0f);
            ElementRoot.anchorMin = new Vector2(0.0f, 0.0f);
            ElementRoot.anchorMax = new Vector2(1.0f, 1.0f);

            //var elementRootImage = elementRootGo.AddComponent< Image >();
            //elementRootImage.sprite = null;
            //elementRootImage.color = new Color( 1.0f, 0.0f, 0.0f, 0.4f );

            // Top Left Text

            var topLeftTextGo = new GameObject("Top Left Text");

            TopLeftTextComponent = topLeftTextGo.AddComponent <Text>();

            TopLeftTextComponent.rectTransform.SetParent(ElementRoot);
            TopLeftTextComponent.rectTransform.anchorMin        = new Vector2(0.0f, 1.0f);
            TopLeftTextComponent.rectTransform.anchorMax        = new Vector2(0.0f, 1.0f);
            TopLeftTextComponent.rectTransform.pivot            = new Vector2(0.0f, 0.0f);
            TopLeftTextComponent.rectTransform.anchoredPosition = new Vector2(0.0f, 0.0f);
            TopLeftTextComponent.rectTransform.sizeDelta        = new Vector2(0.0f, 0.0f);

            TopLeftTextComponent.horizontalOverflow = HorizontalWrapMode.Overflow;
            TopLeftTextComponent.verticalOverflow   = VerticalWrapMode.Overflow;
            TopLeftTextComponent.alignment          = TextAnchor.LowerRight;

            //Font.GetOSInstalledFontNames().ToList().ForEach( fontName => Debug.Log("Found font: " + fontName ));
            TopLeftTextComponent.font     = Font.CreateDynamicFontFromOSFont(FontName, FontSize);
            TopLeftTextComponent.fontSize = FontSize;
        }
示例#6
0
 public ErrorElement(ElementRoot finder) : base(finder)
 {
 }
示例#7
0
 /// <summary>
 /// Finds the control for a provided name
 /// </summary>
 /// <param name="name">Control name</param>
 /// <returns>Control instance or null if not found</returns>
 public new object FindName(string name)
 {
     return(ElementRoot != null ? ElementRoot.FindName(name) : null);
 }
示例#8
0
 public ElementObject(ElementRoot element)
 {
     Element = element;
 }
示例#9
0
 public ProductItem(ElementRoot element) : base(element)
 {
 }
示例#10
0
 public ProductFilter(ElementRoot finder) : base(finder)
 {
 }