Ejemplo n.º 1
0
        public MasterPreviewView(string assetName, PreviewManager previewManager, AbstractMaterialGraph graph)
        {
            this.clippingOptions = ClippingOptions.ClipAndCacheContents;
            m_Graph = graph;

            AddStyleSheetPath("Styles/MasterPreviewView");

            m_PreviewRenderHandle = previewManager.masterRenderData;
            m_PreviewRenderHandle.onPreviewChanged += OnPreviewChanged;

            var topContainer = new VisualElement()
            {
                name = "top"
            };

            {
                var title = new Label(assetName.Split('/').Last())
                {
                    name = "title"
                };
                topContainer.Add(title);
            }
            Add(topContainer);

            var middleContainer = new VisualElement {
                name = "middle"
            };

            {
                m_PreviewTextureView = new PreviewTextureView {
                    name = "preview", image = Texture2D.blackTexture
                };
                m_PreviewTextureView.AddManipulator(new Draggable(OnMouseDragPreviewMesh, true));
                m_PreviewTextureView.AddManipulator((IManipulator)Activator.CreateInstance(s_ContextualMenuManipulator, (Action <ContextualMenuPopulateEvent>)BuildContextualMenu));

                middleContainer.Add(m_PreviewTextureView);

                m_PreviewScrollPosition = new Vector2(0f, 0f);

                middleContainer.Add(m_PreviewTextureView);

                middleContainer.AddManipulator(new Scrollable(OnScroll));
            }
            Add(middleContainer);
        }
Ejemplo n.º 2
0
        public MasterPreviewView(string assetName, PreviewManager previewManager, AbstractMaterialGraph graph)
        {
            m_Graph = graph;

            AddStyleSheetPath("Styles/MaterialGraph");

            m_PreviewRenderHandle = previewManager.masterRenderData;
            m_PreviewRenderHandle.onPreviewChanged += OnPreviewChanged;

            var topContainer = new VisualElement()
            {
                name = "top"
            };

            {
                var title = new Label(assetName + " master node preview")
                {
                    name = "title"
                };
                topContainer.Add(title);
            }
            Add(topContainer);

            var middleContainer = new VisualElement {
                name = "middle"
            };

            {
                m_PreviewTextureView = new PreviewTextureView {
                    name = "preview", image = Texture2D.blackTexture
                };
                m_PreviewTextureView.AddManipulator(new Draggable(OnMouseDragPreviwMesh, true));
                middleContainer.Add(m_PreviewTextureView);

                m_PreviewScrollPosition = new Vector2(0f, 0f);

                middleContainer.Add(m_PreviewTextureView);
            }
            Add(middleContainer);

            var bottomContainer = new VisualElement()
            {
                name = "bottom"
            };

            {
                m_PreviewMeshPicker = new ObjectField {
                    name = "picker", objectType = typeof(Mesh)
                };
                m_PreviewMeshPicker.OnValueChanged(OnPreviewMeshChanged);

                bottomContainer.Add(m_PreviewMeshPicker);
            }
            Add(bottomContainer);
        }
        public GraphInspectorView(string assetName, PreviewManager previewManager, AbstractMaterialGraph graph)
        {
            m_Graph = graph;

            AddStyleSheetPath("Styles/MaterialGraph");

            var topContainer = new VisualElement {
                name = "top"
            };

            {
                var headerContainer = new VisualElement {
                    name = "header"
                };
                {
                    var title = new Label(assetName)
                    {
                        name = "title"
                    };
                    title.AddManipulator(new Clickable(() =>
                    {
                        if (onShowInProjectClick != null)
                        {
                            onShowInProjectClick();
                        }
                    }));
                    headerContainer.Add(title);
                    headerContainer.Add(new Button(() =>
                    {
                        if (onUpdateAssetClick != null)
                        {
                            onUpdateAssetClick();
                        }
                    })
                    {
                        name = "save", text = "Save"
                    });
                }
                topContainer.Add(headerContainer);

                var propertiesContainer = new VisualElement {
                    name = "properties"
                };
                {
                    var header = new VisualElement {
                        name = "header"
                    };
                    {
                        var title = new Label("Properties")
                        {
                            name = "title"
                        };
                        header.Add(title);

                        var addPropertyButton = new Button(OnAddProperty)
                        {
                            text = "Add", name = "addButton"
                        };
                        header.Add(addPropertyButton);
                    }
                    propertiesContainer.Add(header);

                    m_PropertyItems = new VisualContainer {
                        name = "items"
                    };
                    propertiesContainer.Add(m_PropertyItems);
                }
                topContainer.Add(propertiesContainer);
            }
            Add(topContainer);

            var bottomContainer = new VisualElement {
                name = "bottom"
            };

            {
                m_PreviewTextureView = new PreviewTextureView {
                    name = "preview", image = Texture2D.blackTexture
                };
                m_PreviewTextureView.AddManipulator(new Draggable(OnMouseDrag, true));
                bottomContainer.Add(m_PreviewTextureView);

                m_PreviewScrollPosition = new Vector2(0f, 0f);

                m_PreviewMeshPicker = new ObjectField {
                    objectType = typeof(Mesh)
                };
                m_PreviewMeshPicker.OnValueChanged(OnPreviewMeshChanged);

                bottomContainer.Add(m_PreviewMeshPicker);
            }
            Add(bottomContainer);

            m_PreviewRenderHandle = previewManager.masterRenderData;
            m_PreviewRenderHandle.onPreviewChanged += OnPreviewChanged;

            m_PreviewMeshPicker.SetValueAndNotify(m_Graph.previewData.serializedMesh.mesh);

            foreach (var property in m_Graph.properties)
            {
                m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property));
            }

            Add(new ResizeSideHandle(this, ResizeHandleAnchor.TopLeft, new string[] { "resize", "diagonal", "top-left" }));
            Add(new ResizeSideHandle(this, ResizeHandleAnchor.Top, new string[] { "resize", "vertical", "top" }));
            Add(new ResizeSideHandle(this, ResizeHandleAnchor.TopRight, new string[] { "resize", "diagonal", "top-right" }));
            Add(new ResizeSideHandle(this, ResizeHandleAnchor.Right, new string[] { "resize", "horizontal", "right" }));
            Add(new ResizeSideHandle(this, ResizeHandleAnchor.BottomRight, new string[] { "resize", "diagonal", "bottom-right" }));
            Add(new ResizeSideHandle(this, ResizeHandleAnchor.Bottom, new string[] { "resize", "vertical", "bottom" }));
            Add(new ResizeSideHandle(this, ResizeHandleAnchor.BottomLeft, new string[] { "resize", "diagonal", "bottom-left" }));
            Add(new ResizeSideHandle(this, ResizeHandleAnchor.Left, new string[] { "resize", "horizontal", "left" }));
        }