Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HDRP][Compositor] Do not allow users to directly reset/edit the compositor .asset file #1499

Merged
merged 5 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue when Reflection Probes are set to OnEnable and are never rendered if the probe is enabled when the camera is farther than the probe fade distance.
- Fixed issue with sun icon being clipped in the look dev window.
- Fixed error about layers when disabling emissive mesh for area lights.
- Fix issue when the user deletes the composition graph or .asset in runtime (case 1263319)

### Changed
- Improve MIP selection for decals on Transparents
Expand Down Expand Up @@ -942,6 +943,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Changed the color space of EmissiveColorLDR property on all shader. Was linear but should have been sRGB. Auto upgrade script handle the conversion.
- Preparation pass for RTSSShadows to be supported by render graph.
- Add tooltips with the full name of the (graphics) compositor properties to properly show large names that otherwise are clipped by the UI (case 1263590)
- Composition profile .asset files cannot be manually edited/reset by users (to avoid breaking things - case 1265631)

## [7.1.1] - 2019-09-05

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ internal class CompositionUtils
{
public static readonly string k_DefaultCameraName = "MainCompositorCamera";

static public void RemoveCompositionProfileAsset(CompositionManager compositor)
{
if (compositor.profile)
{
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(compositor.profile));
}
}

static public void LoadDefaultCompositionGraph(CompositionManager compositor)
{
if (!AssetDatabase.IsValidFolder("Assets/Compositor"))
Expand Down Expand Up @@ -112,6 +120,9 @@ static public void LoadOrCreateCompositionProfileAsset(CompositionManager compos
Debug.Log($"Loading composition profile from {path}");
}
compositor.profile = newProfile;

// [case 1265631] The profile asset is auto-generated by the compositor, so do not allow the users to manually edit/reset the values in the asset because it might break things.
compositor.profile.hideFlags = HideFlags.NotEditable;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,28 @@ void OnGUI()
}
}

if (compositor.profile == null)
if (compositor.shader == null)
{
// The compositor was loaded, but there was no profile (someone deleted the asset from disk?), so create a new one
CompositionUtils.RemoveCompositionProfileAsset(compositor);
CompositionUtils.LoadDefaultCompositionGraph(compositor);
CompositionUtils.LoadOrCreateCompositionProfileAsset(compositor);
compositor.SetupCompositionMaterial();
return;
m_RequiresRedraw = true;
}

if (compositor.shader != null)
else
{
// keep track of shader graph changes: when the user saves a graph, we should load/reflect any new shader properties
GraphData.onSaveGraph += MarkShaderAsDirty;
}

if (compositor.profile == null)
{
// The compositor was loaded, but there was no profile (someone deleted the asset from disk?), so create a new one
CompositionUtils.LoadOrCreateCompositionProfileAsset(compositor);
compositor.SetupCompositionMaterial();
m_RequiresRedraw = true;
}

if (m_Editor == null || m_Editor.target == null || m_Editor.isDirty || m_RequiresRedraw)
{
m_Editor = (CompositionManagerEditor)Editor.CreateEditor(compositor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ bool ValidateAndFixRuntime()

if (m_Shader == null)
{
Debug.Log("The composition shader graph must be set");
Debug.Log("A composition shader graph must be set in the compositor window");
return false;
}

Expand Down Expand Up @@ -392,12 +392,12 @@ public void SetupCompositionMaterial()
// Create the composition material
if (m_Shader)
{
if (m_Material == null)
{
m_Material = new Material(m_Shader);
}
m_Material = new Material(m_Shader);

m_CompositionProfile.AddPropertiesFromShaderAndMaterial(this, m_Shader, m_Material);

// [case 1265631] The profile asset is auto-generated by the compositor, so do not allow the users to manually edit/reset the values in the asset because it might break things
m_CompositionProfile.hideFlags = HideFlags.NotEditable;
}
else
{
Expand Down
Loading