-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8114 from Unity-Technologies/internal/2021.3/staging
Internal/2021.3/staging
- Loading branch information
Showing
21 changed files
with
675 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...leffectgraph/Documentation~/Block-VelocityFromDirectionAndSpeed(ChangeSpeed).md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...effectgraph/Documentation~/Block-VelocityFromDirectionAndSpeed(NewDirection).md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...ectgraph/Documentation~/Block-VelocityFromDirectionAndSpeed(RandomDirection).md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...ualeffectgraph/Documentation~/Block-VelocityFromDirectionAndSpeed(Spherical).md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...isualeffectgraph/Documentation~/Block-VelocityFromDirectionAndSpeed(Tangent).md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Packages/com.unity.visualeffectgraph/Documentation~/Operator-PointCache.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Packages/com.unity.visualeffectgraph/Documentation~/Operator-SampleAttributeMap.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
Tests/SRPTests/Projects/ShaderGraph/Assets/CommonAssets/Editor/GroupTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using UnityEngine.UIElements; | ||
using NUnit.Framework; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
using UnityEditor.Graphing; | ||
using UnityEditor.ShaderGraph.Drawing; | ||
using UnityEditor.ShaderGraph.Internal; | ||
|
||
|
||
namespace UnityEditor.ShaderGraph.UnitTests | ||
{ | ||
[TestFixture] | ||
internal class GroupTests | ||
{ | ||
static string kGraphName = "Assets/CommonAssets/Graphs/Group.shadergraph"; | ||
GraphData m_Graph; | ||
|
||
GraphEditorView m_GraphEditorView; | ||
MaterialGraphEditWindow m_Window; | ||
|
||
[OneTimeSetUp] | ||
public void LoadGraph() | ||
{ | ||
List<PropertyCollector.TextureInfo> lti; | ||
var assetCollection = new AssetCollection(); | ||
ShaderGraphImporter.GetShaderText(kGraphName, out lti, assetCollection, out m_Graph); | ||
Assert.NotNull(m_Graph, $"Invalid graph data found for {kGraphName}"); | ||
|
||
m_Graph.ValidateGraph(); | ||
// Open up the window | ||
if (!ShaderGraphImporterEditor.ShowGraphEditWindow(kGraphName)) | ||
{ | ||
Assert.Fail("ShaderGraphImporterEditor.ShowGraphEditWindow could not open " + kGraphName); | ||
} | ||
|
||
m_Window = EditorWindow.GetWindow<MaterialGraphEditWindow>(); | ||
if (m_Window == null) | ||
{ | ||
Assert.Fail("Could not open window"); | ||
} | ||
|
||
// EditorWindow.GetWindow will return a new window if one is not found. A new window will have graphObject == null. | ||
if (m_Window.graphObject == null) | ||
{ | ||
Assert.Fail("Existing Shader Graph window of " + kGraphName + " not found."); | ||
} | ||
|
||
m_GraphEditorView = m_Window.graphEditorView; | ||
|
||
} | ||
|
||
class TestExecuteCommandEvent : ExecuteCommandEvent | ||
{ | ||
public void SetCommandName(string command) | ||
{ | ||
commandName = command; | ||
} | ||
} | ||
|
||
[UnityTest] | ||
public IEnumerator TestEmptyGroupPastePosition() | ||
{ | ||
var materialGraphView = m_GraphEditorView.graphView; | ||
var materialGraphViewType = typeof(MaterialGraphView); | ||
|
||
var cutMethodInfo = materialGraphViewType.GetMethod("CutSelectionCallback", | ||
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); | ||
var pasteMethodInfo = materialGraphViewType.GetMethod("PasteCallback", | ||
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); | ||
|
||
var mousePositionPropertyInfo = materialGraphViewType.GetProperty("cachedMousePosition", | ||
typeof(Vector2)); | ||
|
||
Assert.NotNull(cutMethodInfo, "CutSelectionCallback method not found."); | ||
Assert.NotNull(pasteMethodInfo, "PasteCallback method not found."); | ||
Assert.NotNull(mousePositionPropertyInfo, "cachedMousePosition property not found."); | ||
|
||
var groupList = materialGraphView.Query<ShaderGroup>() | ||
.Where(x => x.userData.title == "Empty Group") | ||
.ToList(); | ||
|
||
Assert.AreEqual(1, groupList.Count()); | ||
|
||
|
||
|
||
materialGraphView.ClearSelection(); | ||
materialGraphView.AddToSelection(groupList[0]); | ||
|
||
cutMethodInfo.Invoke(materialGraphView, null); | ||
yield return null; | ||
|
||
groupList = materialGraphView.Query<ShaderGroup>() | ||
.Where(x => x.userData.title == "Empty Group") | ||
.ToList(); | ||
|
||
Assert.AreEqual(0, groupList.Count()); | ||
|
||
mousePositionPropertyInfo.SetValue(materialGraphView, new Vector2(100,100)); | ||
pasteMethodInfo.Invoke(materialGraphView, null); | ||
yield return null; | ||
|
||
mousePositionPropertyInfo.SetValue(materialGraphView, new Vector2(100,200)); | ||
pasteMethodInfo.Invoke(materialGraphView, null); | ||
yield return null; | ||
|
||
groupList = materialGraphView.Query<ShaderGroup>() | ||
.Where(x => x.userData.title == "Empty Group") | ||
.ToList(); | ||
|
||
Assert.AreEqual(2, groupList.Count()); | ||
|
||
Assert.AreNotEqual(groupList[0].GetPosition().position, groupList[1].GetPosition().position, | ||
"When the cursor position changes, the pasted group's position should be adjusted accordingly"); | ||
} | ||
|
||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
Tests/SRPTests/Projects/ShaderGraph/Assets/CommonAssets/Editor/GroupTests.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.