You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
urp-postprocessing: Global Volume template's profile.Add<T>() overrides are lost after Editor restart (never added as sub-assets) #104
skills/urp-postprocessing/references/code-templates.md, "Creating a Global Volume with Effects" (L19–43):
AssetDatabase.CreateAsset(profile, …)
profile.Add<Bloom>() / profile.Add<Tonemapping>()
SetDirty(profile) + AssetDatabase.SaveAssets()
The added VolumeComponents are never stored as sub-assets of the profile. Everything looks right for the rest of the session, but after an Editor restart (or any reload of the asset) the profile has no overrides. We hit exactly this: a color-grading profile built this way came back empty after restarting the Editor.
SKILL.mdL111, L141, L148, L156 present profile.Add<T>() as the way to add overrides, with no Editor-persistence caveat.
Why
VolumeProfile.Add(Type, bool) (com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs L109–123) only does CreateInstance(type) + components.Add(component) — no AssetDatabase.AddObjectToAsset, so the component lives in memory only and the reference does not survive serialization. On the next load VolumeProfile.OnEnable runs components.RemoveAll(x => x == null).
Unity's own Editor code always pairs Add with AddObjectToAsset: Editor/Volume/VolumeComponentListEditor.cs (inspector "Add Override", L518: AssetDatabase.AddObjectToAsset(component, asset)), Editor/Volume/VolumeProfileFactory.cs (VolumeProfileFactory.CreateVolumeComponent<T>, L109), Editor/Volume/VolumeProfileUtils.cs.
The skill's own checks don't catch it
SKILL.mdL87–91 only warns when profile.components.Count == 0; in the same session the list still holds the in-memory instances, so it reports the setup as correct.
code-templates.mdL123–125 says SaveAssets() persists the profile — true for editing existing overrides, not for newly added ones.
Suggested fix
In the template, after each Add<T>(): UnityEditor.AssetDatabase.AddObjectToAsset(bloom, profile); — or use UnityEditor.Rendering.VolumeProfileFactory.CreateVolumeComponent<T>(profile, overrides: true, saveAsset: false), then SaveAssets() once.
Key Facts: "On a profile asset in the Editor, Add<T>() alone is in-memory only; also call AssetDatabase.AddObjectToAsset. A runtime volume.profile instance doesn't need it."
Diagnostic: also warn when EditorUtility.IsPersistent(profile) and any component has !AssetDatabase.IsSubAsset(c).
Activity