RuntimeScriptableObject Class
Definition
Section titled “Definition”Base class for UnityEngine.ScriptableObject that have values that should be resettable.
[HelpURL("https://hertzole.github.io/scriptable-values/guides/creating-custom-types")]public abstract class RuntimeScriptableObject : ScriptableObject, INotifyPropertyChanging, INotifyPropertyChanged, IStackTraceProviderInheritance object → UnityEngine.Object → UnityEngine.ScriptableObject
Implements INotifyPropertyChanging, INotifyPropertyChanged, IStackTraceProvider
Methods
Section titled “Methods”NotifyPropertyChanging(string)
Section titled “NotifyPropertyChanging(string)”Invoke the PropertyChanging event with the given property name.
protected void NotifyPropertyChanging(string propertyName = "")Parameters
Section titled “Parameters”propertyName string
The name of the property that is changing.
NotifyPropertyChanging(PropertyChangingEventArgs)
Section titled “NotifyPropertyChanging(PropertyChangingEventArgs)”Invokes the PropertyChanging event with the given PropertyChangingEventArgs.
protected void NotifyPropertyChanging(PropertyChangingEventArgs args)Parameters
Section titled “Parameters”args PropertyChangingEventArgs
The
NotifyPropertyChanged(string)
Section titled “NotifyPropertyChanged(string)”Invoke the PropertyChanged event and the INotifyBindablePropertyChanged.propertyChanged event with the given property name.
protected void NotifyPropertyChanged(string propertyName = "")Parameters
Section titled “Parameters”propertyName string
The name of the property that has changed.
NotifyPropertyChanged(PropertyChangedEventArgs)
Section titled “NotifyPropertyChanged(PropertyChangedEventArgs)”Invoke the PropertyChanged event and the INotifyBindablePropertyChanged.propertyChanged event with the given PropertyChangedEventArgs.
protected void NotifyPropertyChanged(PropertyChangedEventArgs args)Parameters
Section titled “Parameters”args PropertyChangedEventArgs
The
SetField(ref T, T, string)
Section titled “SetField(ref T, T, string)”Sets a field to a new value and notifies the property changed event.
protected bool SetField<T>(ref T field, T newValue, string propertyName = "")Parameters
Section titled “Parameters”field T
The field to set.
newValue T
The new value to set.
propertyName string
The name of the property that is changing.
Returns
Section titled “Returns”bool
true if the field was changed; otherwise, false.
Remarks
Section titled “Remarks”Calling this will not notify any property changes if the new value is the same as the current field value.
SetField(ref T, T, PropertyChangingEventArgs, PropertyChangedEventArgs)
Section titled “SetField(ref T, T, PropertyChangingEventArgs, PropertyChangedEventArgs)”Sets a field to a new value and notifies the property changed event.
protected bool SetField<T>(ref T field, T newValue, PropertyChangingEventArgs changingArgs, PropertyChangedEventArgs changedArgs)Parameters
Section titled “Parameters”field T
The field to set.
newValue T
The new value to set.
changingArgs PropertyChangingEventArgs
The
changedArgs PropertyChangedEventArgs
The
Returns
Section titled “Returns”bool
true if the field was changed; otherwise, false.
WarnIfLeftOverSubscribers()
Section titled “WarnIfLeftOverSubscribers()”Warns if there are any left-over subscribers to the events.
[Conditional("DEBUG")]protected virtual void WarnIfLeftOverSubscribers()Remarks
Section titled “Remarks”This will only be called in the Unity editor and builds with the DEBUG flag.
AddStackTrace(int)
Section titled “AddStackTrace(int)”Adds a stack trace.
[Conditional("UNITY_EDITOR")]protected void AddStackTrace(int skipFrames = 0)Parameters
Section titled “Parameters”skipFrames int
How many frames/calls to skip.
Remarks
Section titled “Remarks”This only does something in the Unity editor. This method is completely blank in builds.
ResetStackTraces()
Section titled “ResetStackTraces()”Removes all stack traces.
[Conditional("UNITY_EDITOR")]protected void ResetStackTraces()Remarks
Section titled “Remarks”This only does something in the Unity editor. This method is completely blank in builds.
OnPreStart()
Section titled “OnPreStart()”Called when the game starts, before OnStart().
You should not subscribe to events in this method! Use OnStart() instead. OnPreStart() should be used for preparing the scriptable object.
protected virtual void OnPreStart()Remarks
Section titled “Remarks”If this isn’t called when the game starts, it’s called once this scriptable object is loaded and instantiated.
OnStart()
Section titled “OnStart()”Called when the game starts, after OnPreStart().
You should not prepare the object in this method! Use OnPreStart() instead.
protected virtual void OnStart()Remarks
Section titled “Remarks”If this isn’t called when the game starts, it’s called once this scriptable object is loaded and instantiated.
OnPreDisabled()
Section titled “OnPreDisabled()”Called when the game is ending, before OnDisabled().
You should not clean up the object in this method! Use OnDisabled() instead.
protected virtual void OnPreDisabled()Remarks
Section titled “Remarks”This can also be called during the game is the scriptable object is destroyed and/or unloaded.
OnDisabled()
Section titled “OnDisabled()”Called when the game is ending, after OnPreDisabled().
You should not unsubscribe from events in this method! Use OnPreDisabled() instead. OnDisabled() should be used for cleaning up the scriptable object.
protected virtual void OnDisabled()Remarks
Section titled “Remarks”This can also be called during the game is the scriptable object is destroyed and/or unloaded.
OnExitPlayMode()
Section titled “OnExitPlayMode()”Called when the game exits play mode.
[Obsolete("Use either 'OnPreDisabled' or 'OnDisabled' instead.")][ExcludeFromCodeCoverage]protected virtual void OnExitPlayMode()