示例#1
0
        protected override void OnEnable()
        {
            mixtureInspector = target as MixtureNodeInspectorObject;

            nodeInspectorFoldout           = Resources.Load("UI Blocks/InspectorNodeFoldout") as VisualTreeAsset;
            nodeInspectorFoldout.hideFlags = HideFlags.HideAndDontSave;

            base.OnEnable();

            mixtureInspector.pinnedNodeUpdate += UpdateNodeInspectorList;
            previewMaterial = new Material(Shader.Find("Hidden/MixtureInspectorPreview"))
            {
                hideFlags = HideFlags.HideAndDontSave
            };

            // Workaround because UIElements is not able to correctly detect mouse enter / leave events :(
            var repaint = root.schedule.Execute(() => {
                Repaint();
            }).Every(16);

            root.Insert(0, new IMGUIContainer(() => {
                if (selectedNodeList.localBound.Contains(Event.current.mousePosition))
                {
                    repaint.Resume();
                }
                else
                {
                    // Unselect all nodes:
                    foreach (var view in mixtureInspector.selectedNodes)
                    {
                        view.RemoveFromClassList("highlight");
                    }
                    foreach (var view in mixtureInspector.pinnedNodes)
                    {
                        view.RemoveFromClassList("highlight");
                    }
                    repaint.Pause();
                }
            }));
            // End workaround

            // Handle the always refresh option
            root.Add(new IMGUIContainer(() => {
                if (!Application.runInBackground && !UnityEditorInternal.InternalEditorUtility.isApplicationActive && alwaysRefresh)
                {
                    return;
                }

                if (alwaysRefresh)
                {
                    if (Event.current.type == EventType.Layout)
                    {
                        Repaint();
                    }
                }
            }));

            Fit();
        }
        protected override void OnEnable()
        {
            mixtureInspector = target as MixtureNodeInspectorObject;

            nodeInspectorFoldout           = Resources.Load("UI Blocks/InspectorNodeFoldout") as VisualTreeAsset;
            nodeInspectorFoldout.hideFlags = HideFlags.HideAndDontSave;

            base.OnEnable();

            mixtureInspector.pinnedNodeUpdate += UpdateNodeInspectorList;
            previewMaterial = new Material(Shader.Find("Hidden/MixtureInspectorPreview"))
            {
                hideFlags = HideFlags.HideAndDontSave
            };
        }
 public NodeInspectorSettingsPopupWindow(MixtureNodeInspectorObjectEditor inspector)
 {
     this.inspector = inspector;
     this.target    = inspector.mixtureInspector;
 }