Class ScriptableObjectSettingsProvider<TSetting, C>
A helper class for displaying per-build-target ScriptableObject-based settings in the Unity Editor using the SettingsProvider interface.
public class ScriptableObjectSettingsProvider<TSetting, C> : SettingsProvider where TSetting : Settings<TSetting, C> where C : SettingsBuildTargetCollection<TSetting, C>
Type Parameters
| Name | Type | Description |
|---|---|---|
TSetting | The specific settings type for each build target. | |
C | The settings collection type that holds settings for each build target. |
Inheritance
Constructors
ScriptableObjectSettingsProvider(C, SettingsScope, string, IEnumerable<string>)
Initializes a new instance of the ScriptableObjectSettingsProvider class.
public ScriptableObjectSettingsProvider(C settings, SettingsScope scope, string displayPath, IEnumerable<string> keywords = null)
Parameters
| Name | Type | Description |
|---|---|---|
settings | C | The settings collection instance to display. |
scope | SettingsScope | The scope of the settings (User or Project). |
displayPath | string | The display path for the settings in the Unity Settings window. |
keywords | IEnumerable<string> | Optional search keywords for filtering. |
Fields
BUILD_TARGET_NOT_SUPPORTED_TXT
Message displayed when the settings are not applicable to the current build target.
protected const string BUILD_TARGET_NOT_SUPPORTED_TXT = "Settings currently not applicable to this platform."
Field Value
string
m_SettingsWrapper
Serialized object wrapper for the settings collection.
protected SerializedObject m_SettingsWrapper
Field Value
Methods
GetBuildTargetSettings(BuildTargetGroup)
Retrieves the settings associated with a specific build target group. If the settings do not exist, they are created and returned.
protected TSetting GetBuildTargetSettings(BuildTargetGroup buildTargetGroup)
Parameters
| Name | Type | Description |
|---|---|---|
buildTargetGroup | BuildTargetGroup | The build target group for which to retrieve settings. |
Returns
TSetting — The settings for the specified build target group, or null if not supported.
OnBuildTargetSettingsCollectionGUI()
Draws the settings UI for the selected build target settings collection.
protected virtual void OnBuildTargetSettingsCollectionGUI()
OnGUI(string)
Draws the settings UI for the selected build target in the Unity Editor.
public override void OnGUI(string searchContext)
Parameters
| Name | Type | Description |
|---|---|---|
searchContext | string | The current search context in the settings window. |
OnSelectedBuildTargetSettingsGUI(SerializedObject, BuildTargetGroup)
Draws the inspector GUI for the selected build target setting asset.
protected virtual void OnSelectedBuildTargetSettingsGUI(SerializedObject serializedObject, BuildTargetGroup selectedBuildTarget)
Parameters
| Name | Type | Description |
|---|---|---|
serializedObject | SerializedObject | The serialized object representing the settings. |
selectedBuildTarget | BuildTargetGroup | The selected build target. |
TryGetBuildTargetSettings(BuildTargetGroup, out TSetting)
Tries to retrieve the settings for a specific build target group. If the settings exist, they are returned; otherwise, false is returned.
This is a safer version of GetBuildTargetSettings that avoids throwing errors if settings don't exist.
protected bool TryGetBuildTargetSettings(BuildTargetGroup buildTargetGroup, out TSetting settings)
Parameters
| Name | Type | Description |
|---|---|---|
buildTargetGroup | BuildTargetGroup | The build target group for which to try to retrieve settings. |
settings | TSetting | The settings for the specified build target group, or null if not found. |
Returns
bool — True if settings were successfully retrieved, false if not.