This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace UnityEngine.Rendering | |
{ | |
public class VolumeInstanceHelper : MonoBehaviour | |
{ | |
[HideInInspector] | |
public Volume Volume; | |
private void OnValidate() | |
{ | |
if (Volume == null) | |
{ | |
Volume = GetComponent<Volume>(); | |
} | |
} | |
public void CreateProfileInstance() | |
{ | |
var instance = Volume.profile; | |
} | |
public void ClearProfileInstance() | |
{ | |
if (Volume.HasInstantiatedProfile()) | |
{ | |
var profile = Volume.profile; | |
if (profile != Volume.sharedProfile) | |
{ | |
if (Application.isPlaying) | |
{ | |
Destroy(profile); | |
} | |
else | |
{ | |
DestroyImmediate(profile); | |
} | |
} | |
Volume.profile = null; | |
} | |
} | |
} | |
} | |
using UnityEngine; | |
using UnityEngine.Rendering; | |
namespace UnityEditor.Rendering | |
{ | |
[CustomEditor(typeof(VolumeInstanceHelper))] | |
public class VolumeInstanceHelperEditor : Editor | |
{ | |
public override void OnInspectorGUI() | |
{ | |
DrawDefaultInspector(); | |
VolumeInstanceHelper modifier = (VolumeInstanceHelper)target; | |
if (modifier.Volume.HasInstantiatedProfile()) | |
{ | |
EditorGUILayout.Space(); | |
if (GUILayout.Button("Clear instance")) | |
{ | |
modifier.ClearProfileInstance(); | |
} | |
} else | |
{ | |
EditorGUILayout.Space(); | |
if (GUILayout.Button("Create instance")) | |
{ | |
modifier.CreateProfileInstance(); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment