示例#1
0
        public GraphViewParentElement()
        {
            name = "GraphViewParent";

            Toolbar = new ToolbarView();
            Toolbar.style.height   = 20;
            Toolbar.style.flexGrow = 1;
            Toolbar.StretchToParentWidth();
            Add(Toolbar);

            GraphViewElement      = new VisualElement();
            GraphViewElement.name = "GraphView";
            GraphViewElement.StretchToParentSize();
            GraphViewElement.style.top = Toolbar.style.height;
            Add(GraphViewElement);
        }
示例#2
0
        protected virtual void BuildToolbar(ToolbarView toolbar)
        {
            //查看所有节点
            ToolbarButton btnOverview = new ToolbarButton()
            {
                text    = "Overview",
                tooltip = "查看所有节点"
            };

            btnOverview.clicked += () =>
            {
                GraphView.FrameAll();
            };
            toolbar.AddButtonToLeft(btnOverview);
            btnOverview.style.width = 80;

            //跳转视图
            if (jumpAssets.Count > 0)
            {
                IMGUIContainer jumpDrawName = new IMGUIContainer(() =>
                {
                    GUILayout.BeginHorizontal();
                    UnityObject jumpAsset = jumpAssets[0];
                    if (jumpAsset != null && GUILayout.Button(jumpAsset.name, EditorStyles.toolbarButton))
                    {
                        jumpAssets.Remove(jumpAsset);
                        Open(jumpAsset as IGraphAsset);
                    }
                    GUILayout.EndHorizontal();
                });
                jumpDrawName.style.flexGrow = 1;
                toolbar.AddToLeft(jumpDrawName);
            }


            //视图名
            IMGUIContainer drawName = new IMGUIContainer(() =>
            {
                GUILayout.BeginHorizontal();
                if (GraphAsset != null && GUILayout.Button(GraphAsset.name, EditorStyles.toolbarButton))
                {
                    EditorGUIUtility.PingObject(GraphAsset);
                }
                GUILayout.EndHorizontal();
            });

            drawName.style.flexGrow = 1;
            toolbar.AddToLeft(drawName);

            //重新加载
            ToolbarButton btnReload = new ToolbarButton()
            {
                text    = "Reload",
                tooltip = "重新加载",
                style   = { width = 70 }
            };

            btnReload.clicked += Reload;
            toolbar.AddButtonToRight(btnReload);

            //保存
            ToolbarButton btnSave = new ToolbarButton();

            btnSave.text     = "Save";
            btnSave.clicked += Save;
            toolbar.AddButtonToRight(btnSave);
        }