Skip to content

Commit abd46d6

Browse files
julienf-unityEvergreen
authored andcommitted
[6000.5][VFX][UUM-133319] Fix subgraph dependencies
1 parent 6d4d44e commit abd46d6

6 files changed

Lines changed: 76 additions & 0 deletions

File tree

Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/VFXSubgraphBlock.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ public override void GetImportDependentAssets(HashSet<EntityId> dependencies)
3131
}
3232
}
3333

34+
public override void GetSourceDependentAssets(HashSet<string> dependencies)
35+
{
36+
base.GetSourceDependentAssets(dependencies);
37+
if (!object.ReferenceEquals(m_Subgraph, null) && AssetDatabase.TryGetGUIDAndLocalFileIdentifier(m_Subgraph, out var guid, out _))
38+
{
39+
dependencies.Add(guid);
40+
}
41+
}
42+
3443
public override void CheckGraphBeforeImport()
3544
{
3645
base.CheckGraphBeforeImport();

Packages/com.unity.visualeffectgraph/Editor/Models/Contexts/VFXSubgraphContext.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ public override void GetImportDependentAssets(HashSet<EntityId> dependencies)
4848
}
4949
}
5050

51+
public override void GetSourceDependentAssets(HashSet<string> dependencies)
52+
{
53+
base.GetSourceDependentAssets(dependencies);
54+
if (!object.ReferenceEquals(m_Subgraph, null) && AssetDatabase.TryGetGUIDAndLocalFileIdentifier(m_Subgraph, out var guid, out _))
55+
{
56+
dependencies.Add(guid);
57+
}
58+
}
59+
5160
void GraphParameterChanged(VFXGraph graph)
5261
{
5362
VisualEffectAsset asset = graph != null && graph.GetResource() != null ? graph.GetResource().asset : null;

Packages/com.unity.visualeffectgraph/Editor/Models/Operators/VFXSubgraphOperator.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,15 @@ public override void GetImportDependentAssets(HashSet<EntityId> dependencies)
195195
}
196196
}
197197

198+
public override void GetSourceDependentAssets(HashSet<string> dependencies)
199+
{
200+
base.GetSourceDependentAssets(dependencies);
201+
if (!object.ReferenceEquals(m_Subgraph, null) && AssetDatabase.TryGetGUIDAndLocalFileIdentifier(m_Subgraph, out var guid, out _ ))
202+
{
203+
dependencies.Add(guid);
204+
}
205+
}
206+
198207
protected internal override void Invalidate(VFXModel model, InvalidationCause cause)
199208
{
200209
if (cause == InvalidationCause.kSettingChanged)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:943a0117d5abb20763f0313ec036a10bf78ffc6a3138d4af9086d528db9ef5be
3+
size 8726

Tests/SRPTests/Packages/com.unity.testing.visualeffectgraph/Tests/Editor/Data/Repro_Simplest_Subgraph_Chain.unitypackage.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/SRPTests/Packages/com.unity.testing.visualeffectgraph/Tests/Editor/VFXSanitizeTest.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,5 +355,44 @@ public IEnumerator Change_VFX_Exposed_Properties_With_Order_Two_Subgraph([ValueS
355355

356356
yield return null;
357357
}
358+
359+
static bool FindInShaderSource(VisualEffectResource vfxResource, string match)
360+
{
361+
for (int shaderIndex = 0; shaderIndex < vfxResource.GetShaderSourceCount(); ++shaderIndex)
362+
{
363+
var shaderSource = vfxResource.GetShaderSource(shaderIndex);
364+
if (shaderSource.Contains(match))
365+
return true;
366+
}
367+
368+
return false;
369+
}
370+
371+
[UnityTest, Description("Cover UUM-133319")]
372+
public IEnumerator Repro_Simplest_Subgraph_Chain()
373+
{
374+
VFXViewWindow.GetAllWindows().ToList().ForEach(x => { x.Close(); });
375+
AssetDatabase.ImportPackageImmediately("Packages/com.unity.testing.visualeffectgraph/Tests/Editor/Data/Repro_Simplest_Subgraph_Chain.unitypackage");
376+
AssetDatabase.Refresh();
377+
yield return null;
378+
379+
var mainGraphPath = Path.Combine(VFXTestCommon.tempBasePath, "Repro_Simplest_Subgraph_Chain.vfx");
380+
var subGraphPath = Path.Combine(VFXTestCommon.tempBasePath, "Repro_Simplest_Subgraph_Chain.vfxblock");
381+
382+
var mainGraphAsset = AssetDatabase.LoadAssetAtPath<VisualEffectAsset>(mainGraphPath);
383+
var subGraphAsset = AssetDatabase.LoadAssetAtPath<VisualEffectSubgraph>(subGraphPath);
384+
Assert.IsNotNull(mainGraphAsset);
385+
Assert.IsNotNull(subGraphAsset);
386+
387+
Assert.IsTrue(FindInShaderSource(mainGraphAsset.GetResource(), "void Gravity"));
388+
389+
var subgraphContext = subGraphAsset.GetResource().GetOrCreateGraph().children.Single();
390+
var gravity = subgraphContext.children.OfType<Block.Gravity>().Single();
391+
subgraphContext.RemoveChild(gravity);
392+
subGraphAsset.GetResource().WriteAsset();
393+
yield return null;
394+
395+
Assert.IsFalse(FindInShaderSource(mainGraphAsset.GetResource(), "void Gravity"));
396+
}
358397
}
359398
}

0 commit comments

Comments
 (0)