Class StaticActor
This is a generic Singleton implementation for components.
Create a derived class of the script you want to "Singletonize"
Inherited Members
Namespace: Exiled.API.Features.Core
Assembly: Exiled.API.dll
Syntax
public abstract class StaticActor : EActor, IEntity, IWorldSpace, IPosition, IRotation
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 component exist in the scene.
You can override this method in derived classes to customize the initialization of the component.
CreateNewInstance(Type)
Creates a new instance of the StaticActor.
Declaration
public static StaticActor CreateNewInstance(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | The type of the StaticActor. |
Returns
| Type | Description |
|---|---|
| StaticActor | The created StaticActor instance, or null if not found. |
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 component exist in the scene.
You can override this method in derived classes to customize the initialization of the component.
Flush()
Flushes the current actor.
Declaration
protected virtual void Flush()
Get(Type)
Gets a StaticActor given the specified type.
Declaration
public static StaticActor Get(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | The the type of the StaticActor to look for. |
Returns
| Type | Description |
|---|---|
| StaticActor | The corresponding StaticActor. |
Get<T>()
Gets a StaticActor given the specified type T.
Declaration
public static T Get<T>()
where T : StaticActor
Returns
| Type | Description |
|---|---|
| T | The corresponding StaticActor, or null if not found. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the StaticActor to look for. |
Get<T>(Type)
Gets a StaticActor given the specified type.
Declaration
public static T Get<T>(Type type)
where T : StaticActor
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | The the type of the StaticActor to look for. |
Returns
| Type | Description |
|---|---|
| T | The corresponding StaticActor of type |
Type Parameters
| Name | Description |
|---|---|
| T | The type to cast the StaticActor to. |
NotifyInstanceRepeated()
If a duplicated instance of a StaticActor 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 component exist in the scene.
You can override this method in derived classes to customize the initialization of the component.