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; }
/// <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 { })
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; }
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; }
public ErrorElement(ElementRoot finder) : base(finder) { }
/// <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); }
public ElementObject(ElementRoot element) { Element = element; }
public ProductItem(ElementRoot element) : base(element) { }
public ProductFilter(ElementRoot finder) : base(finder) { }