From 5fe9975812e5075f9b4caa46a75e3a9b011630ac Mon Sep 17 00:00:00 2001 From: julienf-unity Date: Tue, 21 Apr 2020 21:35:40 +0200 Subject: [PATCH 1/2] Dont remove suboutputs objects if it cannot be deserialized --- .../Implementations/VFXAbstractRenderedOutput.cs | 13 ++++--------- .../Editor/Models/Contexts/VFXSRPSubOutput.cs | 4 ++++ .../Editor/Models/VFXGraph.cs | 6 +++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/com.unity.visualeffectgraph/Editor/Models/Contexts/Implementations/VFXAbstractRenderedOutput.cs b/com.unity.visualeffectgraph/Editor/Models/Contexts/Implementations/VFXAbstractRenderedOutput.cs index 9592f100020..20dbef8a162 100644 --- a/com.unity.visualeffectgraph/Editor/Models/Contexts/Implementations/VFXAbstractRenderedOutput.cs +++ b/com.unity.visualeffectgraph/Editor/Models/Contexts/Implementations/VFXAbstractRenderedOutput.cs @@ -113,10 +113,9 @@ private void SanitizeSubOutputs() return; } - // TODO Uncommenting this code will removed SRP data that are unknown, this is probably not what we want - //int nbRemoved = 0; - //if ((nbRemoved = m_SubOutputs.RemoveAll(s => s == null)) > 0) - // Debug.LogWarningFormat("Remove {0} SRP Sub Outputs that could not be deserialized from {1} of type {2}", nbRemoved, name, GetType()); + // Reference equals because we only need to remove actual null sub-output, not the ones that cannot be deserialized + // Because we want to keep reference to unknown SRP outputs. No log because this is internal clean up + m_SubOutputs.RemoveAll(s => object.ReferenceEquals(s, null)); var subOutputsTypes = new HashSet(); // TODO For some reason constructor that takes a capacity does not exist for (int i = 0; i < m_SubOutputs.Count; ++i) @@ -140,11 +139,7 @@ public override void CollectDependencies(HashSet objs, bool ow { base.CollectDependencies(objs, ownedOnly); foreach (var data in m_SubOutputs) - if (data != null) - { - objs.Add(data); - data.CollectDependencies(objs, ownedOnly); - } + objs.Add(data); } public override VFXSetting GetSetting(string name) diff --git a/com.unity.visualeffectgraph/Editor/Models/Contexts/VFXSRPSubOutput.cs b/com.unity.visualeffectgraph/Editor/Models/Contexts/VFXSRPSubOutput.cs index 296b1db3d59..1fb1f8816fa 100644 --- a/com.unity.visualeffectgraph/Editor/Models/Contexts/VFXSRPSubOutput.cs +++ b/com.unity.visualeffectgraph/Editor/Models/Contexts/VFXSRPSubOutput.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using UnityEngine; using static UnityEditor.VFX.VFXAbstractRenderedOutput; namespace UnityEditor.VFX @@ -24,6 +25,9 @@ public void Init(VFXAbstractRenderedOutput owner) public virtual bool supportsExposure { get { return false; } } public virtual bool supportsMotionVector { get { return false; } } + // Sealed override as SRP suboutputs cannot have dependencies + public sealed override void CollectDependencies(HashSet objs, bool ownedOnly = true) {} + public virtual string GetBlendModeStr() { switch (owner.blendMode) diff --git a/com.unity.visualeffectgraph/Editor/Models/VFXGraph.cs b/com.unity.visualeffectgraph/Editor/Models/VFXGraph.cs index c98f954d8a9..c1c2f612adf 100644 --- a/com.unity.visualeffectgraph/Editor/Models/VFXGraph.cs +++ b/com.unity.visualeffectgraph/Editor/Models/VFXGraph.cs @@ -277,7 +277,11 @@ public object Backup() dependencies.Add(this); CollectDependencies(dependencies); - var result = VFXMemorySerializer.StoreObjectsToByteArray(dependencies.Cast().ToArray(), CompressionLevel.Fastest); + // This is a guard where dependencies that couldnt be deserialized (because script is missing for instance) are removed from the list + // because else StoreObjectsToByteArray is crashing + // TODO Fix that + var safeDependencies = dependencies.Where(o => o != null); + var result = VFXMemorySerializer.StoreObjectsToByteArray(safeDependencies.ToArray(), CompressionLevel.Fastest); Profiler.EndSample(); From c8ff6bef3099eb3226de614459dd164f5ca09b44 Mon Sep 17 00:00:00 2001 From: julienf-unity Date: Tue, 21 Apr 2020 21:56:32 +0200 Subject: [PATCH 2/2] Update changelog --- com.unity.visualeffectgraph/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.visualeffectgraph/CHANGELOG.md b/com.unity.visualeffectgraph/CHANGELOG.md index 07c8dc636a0..4db9a486032 100644 --- a/com.unity.visualeffectgraph/CHANGELOG.md +++ b/com.unity.visualeffectgraph/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix various bugs in Position (Cone) block [Case 1111053](https://issuetracker.unity3d.com/product/unity/issues/guid/1111053/) - Fix space issues with blocks and operators taking a camera as input - Generated shaderName are now consistent with displayed system names +- Don't lose SRP output specific data when SRP package is not present ## [8.0.1] - 2020-02-25