-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add auto-switch option for Volume access type
- Add `autoSwitchVolumeAccessType` toggle to control access type behavior - When enabled: automatically switches between Profile/SharedProfile based on play mode - When disabled: allows manual selection of access type
- Loading branch information
1 parent
5ae7734
commit ceed340
Showing
6 changed files
with
93 additions
and
38 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
|
||
namespace MAOTimelineExtension.Editor | ||
{ | ||
[CustomEditor(typeof(MAOTimelineExtensionVolumeSettings))] | ||
public class MAOTimelineExtensionVolumeSettingsEditor : UnityEditor.Editor | ||
{ | ||
SerializedProperty autoSwitchVolumeAccessType; | ||
SerializedProperty manualVolumeAccessType; | ||
|
||
private void OnEnable() | ||
{ | ||
autoSwitchVolumeAccessType = serializedObject.FindProperty("autoSwitchVolumeAccessType"); | ||
manualVolumeAccessType = serializedObject.FindProperty("manualVolumeAccessType"); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.Update(); | ||
|
||
EditorGUILayout.PropertyField(autoSwitchVolumeAccessType, new GUIContent("Auto Switch Access Type")); | ||
|
||
using (new EditorGUI.DisabledGroupScope(autoSwitchVolumeAccessType.boolValue)) | ||
{ | ||
EditorGUILayout.PropertyField(manualVolumeAccessType, new GUIContent("Volume Access Type")); | ||
} | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,8 @@ namespace MAOTimelineExtension | |
public class MAOTimelineExtensionVolumeSettings : MonoBehaviour | ||
{ | ||
// https://docs.unity3d.com/Packages/[email protected]/manual/Volumes-API.html#access-a-shared-volume-profile | ||
[Tooltip(""+ | ||
@"- Access a shared Volume Profile | ||
[Tooltip("" + | ||
@"- Access a shared Volume Profile | ||
One method is to access the Volume's shared Profile. You do this via the Volume's sharedProfile property. This gives you a reference to the instance of the Volume Profile asset. | ||
If you modify this Volume Profile: | ||
- HDRP applies any changes you make to every Volume that uses this Volume Profile asset. | ||
|
@@ -26,7 +26,22 @@ The other method is to clone the Volume Profile asset. The advantage of this is | |
- The modification you make reset when you exit Play mode. | ||
- It is your responsibility to destroy the duplicate Volume Profile when you no longer need it. | ||
Note that you can use this property to assign a different Volume Profile to the Volume.")] | ||
public VolumeAccessType volumeAccessType = VolumeAccessType.Profile; | ||
|
||
[SerializeField] private VolumeAccessType manualVolumeAccessType = VolumeAccessType.Profile; | ||
|
||
private VolumeAccessType volumeAccessType | ||
{ | ||
get | ||
{ | ||
if (!autoSwitchVolumeAccessType) | ||
return manualVolumeAccessType; | ||
|
||
return Application.isPlaying ? VolumeAccessType.Profile : VolumeAccessType.SharedProfile; | ||
} | ||
} | ||
|
||
|
||
[SerializeField] private bool autoSwitchVolumeAccessType = true; | ||
|
||
private Volume _volume; | ||
private Volume VolumeComponent | ||
|
@@ -48,7 +63,9 @@ public VolumeProfile VolumeProfile | |
{ | ||
if (_volumeProfile == null) | ||
{ | ||
_volumeProfile = volumeAccessType == VolumeAccessType.Profile? VolumeComponent.profile : VolumeComponent.sharedProfile; | ||
_volumeProfile = volumeAccessType == VolumeAccessType.Profile | ||
? VolumeComponent.profile | ||
: VolumeComponent.sharedProfile; | ||
} | ||
return _volumeProfile; | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.