示例#1
0
        public IEnumerator ResetPropertyReference()
        {
            var fieldViewElements = m_GraphEditorView.Query("blackboardFieldView");

            foreach (var visualElement in fieldViewElements.ToList())
            {
                var blackboardPropertyView = (SGBlackboardField)visualElement;
                if (blackboardPropertyView == null)
                {
                    continue;
                }

                var shaderInput           = (AbstractShaderProperty)blackboardPropertyView.shaderInput;
                var originalReferenceName = shaderInput.referenceName;
                var propertyType          = shaderInput.GetPropertyTypeString();
                var modifiedReferenceName = $"{propertyType}_Test";
                shaderInput.SetReferenceNameAndSanitizeForGraph(m_Graph, modifiedReferenceName);

                Assert.IsTrue(shaderInput.referenceName != originalReferenceName);
                ShaderGraphUITestHelpers.SendMouseEvent(m_Window, blackboardPropertyView, EventType.MouseDown);

                // Needed so that the inspector gets triggered and the callbacks and triggers are initialized
                ShaderGraphUITestHelpers.SendMouseEvent(m_Window, blackboardPropertyView, EventType.MouseDown);

                // Wait a frame for the inspector updates to trigger
                yield return(null);

                ShaderGraphUITestHelpers.SendMouseEvent(m_Window, blackboardPropertyView, EventType.MouseUp);

                // Wait a frame for the inspector updates to trigger
                yield return(null);

                // Cannot actually spawn the right click menu for testing due to ContextMenuManipulators spawning
                // an OS level menu that steals focus from Editor and preventing any future events from being processed
                // Instead, we trigger the action directly from code, for now...
                shaderInput.ResetReferenceName(m_Graph);

                if (shaderInput.referenceName != originalReferenceName)
                {
                    Assert.Fail("Failed to reset reference name to original value.");
                }
            }
        }
示例#2
0
        public IEnumerator ResetPropertyReference()
        {
            var fieldViewElements = m_GraphEditorView.Query("blackboardFieldView");

            foreach (var visualElement in fieldViewElements.ToList())
            {
                var blackboardPropertyView = (SGBlackboardField)visualElement;
                if (blackboardPropertyView == null)
                {
                    continue;
                }

                var shaderInput           = (AbstractShaderProperty)blackboardPropertyView.shaderInput;
                var originalReferenceName = shaderInput.referenceName;
                var propertyType          = shaderInput.GetPropertyTypeString();
                var modifiedReferenceName = $"{propertyType}_Test";
                shaderInput.SetReferenceNameAndSanitizeForGraph(m_Graph, modifiedReferenceName);

                Assert.IsTrue(shaderInput.referenceName != originalReferenceName);
                m_GraphEditorView.graphView.ClearSelection();
                m_GraphEditorView.graphView.AddToSelection(blackboardPropertyView);
                Assert.AreEqual(1, m_Window.graphEditorView.graphView.selection.Count(), "Could not select property!");

                // Wait a frame for the inspector updates to trigger
                yield return(null);


                // Cannot actually spawn the right click menu for testing due to ContextMenuManipulators spawning
                // an OS level menu that steals focus from Editor and preventing any future events from being processed
                // Instead, we trigger the action directly from code, for now...
                shaderInput.ResetReferenceName(m_Graph);

                if (shaderInput.referenceName != originalReferenceName)
                {
                    Assert.Fail("Failed to reset reference name to original value.");
                }
            }
        }