Photon Bolt Engine API 1.3

Static Public Member Functions | Static Protected Attributes | Properties | List of all members
Photon.Bolt.BoltSingletonPrefab< T > Class Template Reference

Base class for monobehaviours that can be accessed as a singleton. The singleton is instantiated from the resources folder and should have the same name as the class type. More...

Inheritance diagram for Photon.Bolt.BoltSingletonPrefab< T >:

Static Public Member Functions

static void Instantiate ()
 Create an instance of the singleton prefab More...
 

Static Protected Attributes

static string _resourcePath
 

Properties

static T instance [get]
 Returns the singleton instance of this type More...
 

Detailed Description

Base class for monobehaviours that can be accessed as a singleton. The singleton is instantiated from the resources folder and should have the same name as the class type.

Template Parameters
TThe name of the type and name of the prefab inside resources folder

Example: Using as a base class for PlayerCamera script.

public class PlayerCamera : BoltSingletonPrefab<PlayerCamera> {
Transform _target;
public new Camera camera {
get { return _camera; }
}
}
Type Constraints
T :MonoBehaviour 

Member Function Documentation

◆ Instantiate()

static void Photon.Bolt.BoltSingletonPrefab< T >.Instantiate ( )
inlinestatic

Create an instance of the singleton prefab

Example: Instantiate a player camera and game hud instance when the local scene is loaded. These will be cloned from from prefabs inside a Resources folder that have the same name as the type ("PlayerCamera" and "GameHUD").

public override void SceneLoadLocalDone(string map) {
if(map.Equals("Game")) {
GameHUD.Instantiate();
PlayerCamera.Instantiate();
}
}

Member Data Documentation

◆ _resourcePath

string Photon.Bolt.BoltSingletonPrefab< T >._resourcePath
staticprotected

Property Documentation

◆ instance

T Photon.Bolt.BoltSingletonPrefab< T >.instance
staticget

Returns the singleton instance of this type

Example: Using the player camera singleton

public override void ControlOfEntityGained(BoltEntity entity {
PlayerCamera.instance.SetTarget(entity);
}