Unity-NorthStar / data /Packages /com.unity.render-pipelines.universal /Runtime /RendererFeatures /FullScreenPassRendererFeature_OldGUID.cs
| // UUM-92491: This solve an issue where in 2022.3 FullScreenPassRendererFeature got introduced with another | |
| // guid than in the 6000.0 version. To update the GUID, we are bound to this strange inheritance and migration. | |
| // See also FullScreenPassRendererFeature_OldGUIDEditor, for the in editor downcasting. | |
| using UnityEditor; | |
| using UnityEngine; | |
| [] | |
| class FullScreenPassRendererFeature_OldGUID : UnityEngine.Rendering.Universal.FullScreenPassRendererFeature, ISerializationCallbackReceiver | |
| { | |
| void ISerializationCallbackReceiver.OnAfterDeserialize() | |
| { | |
| // InternalCreate cannot be called in serialization callback... Delaying | |
| EditorApplication.delayCall += DownCast; | |
| } | |
| void DownCast() | |
| { | |
| if (this == null || this.Equals(null)) return; | |
| const string newGUID = "b00045f12942b46c698459096c89274e"; | |
| const string oldGUID = "6d613f08f173d4dd895bb07b3230baa9"; | |
| // Check current GUID to be extra sure it is the old one to update | |
| var serializedObject = new SerializedObject(this); | |
| var scriptProperty = serializedObject.FindProperty("m_Script"); | |
| MonoScript currentScript = scriptProperty.objectReferenceValue as MonoScript; | |
| AssetDatabase.TryGetGUIDAndLocalFileIdentifier(currentScript.GetInstanceID(), out var currentGUID, out var _); | |
| if (currentGUID != oldGUID) | |
| return; | |
| // Mutate to base FullScreenPassRendererFeature script | |
| var newScript = AssetDatabase.LoadAssetAtPath<MonoScript>(AssetDatabase.GUIDToAssetPath(newGUID)); | |
| scriptProperty.objectReferenceValue = newScript; | |
| serializedObject.ApplyModifiedProperties(); | |
| } | |
| } | |