generated from vrchat-community/template-package
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for disabling preview on a pass or plugin basis
Closes: #296
- Loading branch information
1 parent
903b598
commit 2807243
Showing
15 changed files
with
380 additions
and
21 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
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
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace nadena.dev.ndmf.preview.UI | ||
{ | ||
internal class PreviewPrefs : ScriptableSingleton<PreviewPrefs> | ||
{ | ||
[SerializeField] private List<string> _disabledPreviewPasses = new(); | ||
private ImmutableHashSet<string> _disabledPreviewPassesSet; | ||
|
||
[SerializeField] private List<string> _disabledPreviewPlugins = new(); | ||
private ImmutableHashSet<string> _disabledPreviewPluginsSet; | ||
|
||
public event Action OnPreviewConfigChanged; | ||
|
||
private void OnValidate() | ||
{ | ||
_disabledPreviewPassesSet = _disabledPreviewPasses.ToImmutableHashSet(); | ||
_disabledPreviewPluginsSet = _disabledPreviewPlugins.ToImmutableHashSet(); | ||
} | ||
|
||
public bool IsPreviewPassEnabled(string qualifiedName) | ||
{ | ||
if (_disabledPreviewPassesSet == null) OnValidate(); | ||
|
||
return !_disabledPreviewPassesSet.Contains(qualifiedName); | ||
} | ||
|
||
public bool IsPreviewPluginEnabled(string qualifiedName) | ||
{ | ||
if (_disabledPreviewPluginsSet == null) OnValidate(); | ||
|
||
return !_disabledPreviewPluginsSet.Contains(qualifiedName); | ||
} | ||
|
||
public void SetPreviewPassEnabled(string qualifiedName, bool enabled) | ||
{ | ||
if (enabled) | ||
_disabledPreviewPasses.Remove(qualifiedName); | ||
else | ||
_disabledPreviewPasses.Add(qualifiedName); | ||
|
||
OnValidate(); | ||
|
||
OnPreviewConfigChanged?.Invoke(); | ||
} | ||
|
||
public void SetPreviewPluginEnabled(string qualifiedName, bool enabled) | ||
{ | ||
if (enabled) | ||
_disabledPreviewPlugins.Remove(qualifiedName); | ||
else | ||
_disabledPreviewPlugins.Add(qualifiedName); | ||
|
||
OnValidate(); | ||
|
||
OnPreviewConfigChanged?.Invoke(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.