コード例 #1
0
ファイル: MurpleEntry.cs プロジェクト: eugeneUG/Murple
    public MurpleUIElement AddUIElement(MurpleUIElement.Type type, string name, RectTransform contentRectTransform)
    {
        MurpleUIElement newUIElement = null;

        if (type == MurpleUIElement.Type.InputField)
        {
            InputField newInputField = InputField.Instantiate<InputField>(InputFieldTemplate);
            newUIElement = new MurpleUIElement(type, newInputField);

            newInputField.transform.SetParent(contentRectTransform.transform);
            SetupUIElement(newUIElement);

            newInputField.text = name;

            newInputField.onEndEdit.AddListener(newUIElement.OnInputFieldChanged);
        }
        if (type == MurpleUIElement.Type.Dropdown)
        {
            Dropdown newDropdown = Dropdown.Instantiate<Dropdown>(DropdownTemplate);
            newUIElement = new MurpleUIElement(type, newDropdown);

            newDropdown.transform.SetParent(contentRectTransform.transform);
            SetupUIElement(newUIElement);

            newDropdown.onValueChanged.AddListener(newUIElement.OnDropdownChanged);
        }

        newUIElement.UIElement.name = name;
        mMurpleUIElement.Add(name, newUIElement);

        return newUIElement;
    }
コード例 #2
0
ファイル: MurpleUIElement.cs プロジェクト: eugeneUG/Murple
 public MurpleUIElement(MurpleUIElement.Type elementType, Selectable selectable)
 {
     mElementType = elementType;
     mSelectable = selectable;
     mRectTransform = mSelectable.GetComponent<RectTransform>();
 }
コード例 #3
0
ファイル: MurpleEntry.cs プロジェクト: eugeneUG/Murple
 private void SetupUIElement(MurpleUIElement uiElement)
 {
     uiElement.UITransform.anchoredPosition3D = new Vector3(0, 0, 0);
     uiElement.UITransform.localScale = new Vector3(1, 1, 1);
 }