Class StaticActor<T>
This is a generic Singleton implementation for components.
Create a derived class where the type T
is the script you want to "Singletonize"
Inherited Members
Namespace: Exiled.API.Features.Core.Generic
Assembly: Exiled.API.dll
Syntax
public abstract class StaticActor<T> : EActor, IEntity, IWorldSpace, IPosition, IRotation where T : EActor
Type Parameters
Name | Description |
---|---|
T | The type of the class. |
Remarks
Do not redefine PostInitialize() OnBeginPlay() or OnEndPlay() in derived classes.
Instead, use langword_csharp_protected virtual methods:
PostInitialize_Static()
BeginPlay_Static()
EndPlay_Static()
To perform the initialization and cleanup: those methods are guaranteed to only be called once in the entire lifetime of the component.
Properties
| Improve this Doc View SourceIsDestroyed
Gets a value indicating whether the OnEndPlay() method has already been called by Unity.
Declaration
public bool IsDestroyed { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsInitialized
Gets a value indicating whether the PostInitialize() method has already been called by Unity.
Declaration
public bool IsInitialized { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsStarted
Gets a value indicating whether the OnBeginPlay() method has already been called by Unity.
Declaration
public bool IsStarted { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceBeginPlay_Static()
Fired on OnBeginPlay().
Declaration
protected virtual void BeginPlay_Static()
Remarks
This method will only be called once even if multiple instances of the StaticActor<T> component exist in the scene.
You can override this method in derived classes to customize the initialization of the component.
CreateNewInstance()
Creates a new instance of the StaticActor<T>.
Declaration
public static T CreateNewInstance()
Returns
Type | Description |
---|---|
T | The created |
EndPlay_Static()
Fired on OnEndPlay().
Declaration
protected virtual void EndPlay_Static()
Remarks
This method will only be called once even if multiple instances of the StaticActor<T> component exist in the scene.
You can override this method in derived classes to customize the initialization of the component.
FindExistingInstance()
Looks for an existing instance of the StaticActor<T>.
Declaration
public static T FindExistingInstance()
Returns
Type | Description |
---|---|
T | The existing |
Flush()
Flushes the current actor.
Declaration
protected virtual void Flush()
Get()
Gets or creates a new instance of StaticActor<T>.
Declaration
public static T Get()
Returns
Type | Description |
---|---|
T | The found or created |
NotifyInstanceRepeated()
If a duplicated instance of a StaticActor<T> component is loaded into the scene this method will be called instead of PostInitialize_Static().
That way you can customize what to do with repeated instances.
Declaration
protected virtual void NotifyInstanceRepeated()
Remarks
The default approach is delete the duplicated component.
OnBeginPlay()
Declaration
protected override void OnBeginPlay()
Overrides
| Improve this Doc View SourceOnEndPlay()
Declaration
protected override void OnEndPlay()
Overrides
| Improve this Doc View SourcePostInitialize()
Declaration
protected override void PostInitialize()
Overrides
| Improve this Doc View SourcePostInitialize_Static()
Fired on PostInitialize().
Declaration
protected virtual void PostInitialize_Static()
Remarks
This method will only be called once even if multiple instances of the StaticActor<T> component exist in the scene.
You can override this method in derived classes to customize the initialization of the component.