Esempio n. 1
0
        public void OnEnable()
        {
            var root = this.rootVisualElement;

            Toolbar t = new Toolbar();

            root.Add(t);

            ToolbarToggle tg = new ToolbarToggle()
            {
                text = "tg1"
            };

            t.Add(tg);
            tg = new ToolbarToggle()
            {
                text = "tg2"
            };
            t.Add(tg);
            tg.RegisterValueChangedCallback(toggleChanged);
            tg.RegisterCallback <ChangeEvent <bool> >(toggleListener);

            m_ObjectNameBinding             = new TextField("Width");
            m_ObjectNameBinding.bindingPath = "m_SizeDelta.x";
            root.Add(m_ObjectNameBinding);
            m_ObjectNameBinding             = new TextField("Object Name Binding");
            m_ObjectNameBinding.bindingPath = "m_Name";
            root.Add(m_ObjectNameBinding);
            OnSelectionChange();
        }
        public AssetTablesWindowToolbar()
        {
            var root = Resources.GetTemplate("AssetTablesWindowToolbar");

            Add(root);
            root.StretchToParentSize();

            NewButton  = root.Q <ToolbarToggle>("toolbarButtonNew");
            EditButton = root.Q <ToolbarToggle>("toolbarButtonEdit");

            NewButton.RegisterCallback <ChangeEvent <bool> >(evt =>
            {
                if (evt.newValue)
                {
                    ShowNewCallback();
                }
            });
            EditButton.RegisterCallback <ChangeEvent <bool> >(evt =>
            {
                if (evt.newValue)
                {
                    ShowEditCallback();
                }
            });

            selectedPanel = (SelectedPanel)EditorPrefs.GetInt(k_SelectedTabPref, 0);

            if (selectedPanel == SelectedPanel.NewTables)
            {
                NewButton.value = true;
                ShowNewCallback();
            }
            else
            {
                EditButton.value = true;
                ShowEditCallback();
            }
        }
Esempio n. 3
0
    public override VisualElement CreateInspectorGUI()
    {
        t = target as WaypointPath;

        var root = rootElement;

        root.Clear();

        box = new Box();
        box.style.minHeight = 100;
        box.RegisterCallback <MouseDownEvent>(OnBoxClicked);

        var toolbar = new Toolbar();

        var addButton = new ToolbarButton(() => { AddWaypoint(target as WaypointPath); })
        {
            text = "Add Point"
        };

        bezierToggle = new ToolbarToggle()
        {
            text = "Draw Bezier"
        };
        bezierToggle.value = t.drawBezier;
        bezierToggle.RegisterCallback <ChangeEvent <bool> >(OnToggleValueChange);

        var spacer = new ToolbarSpacer();

        spacer.style.flexGrow = 1;

        var clearButton = new ToolbarButton(ClearWaypoints)
        {
            text = "Clear Points"
        };

        toolbar.Add(addButton);
        toolbar.Add(bezierToggle);
        toolbar.Add(spacer);
        toolbar.Add(clearButton);

        actionContainer = new ScrollView();
        actionContainer.showHorizontal = false;
        box.Add(toolbar);
        box.Add(actionContainer);

        //TODO: Add previously added tasks to the box

        root.Add(box);

        var button = new Button(() => { t.UpdateWorldPoints(); });

        button.text = "Update World Points";
        root.Add(button);

        if (t.points != null)
        {
            for (int i = 0; i < t.points.Count; i++)
            {
                CreateWaypointElement(i.ToString(), t.points[i]);
            }
        }

        return(root);
    }