â ī¸Important Workflows
Important C# scripting workflows that must be followed to reduce hard to find errors and other problems.
Singleton C#
For Singleton
that's part of a Networked GameObject and will be referenced through scripts attached to different objects, ie. BaseTimeFrameManager.cs
that's under GameManager
but another non-networked script like TimeMachine.cs
will access it, we need to initialize in get instead of Awake to prevent execution order problems.
//New approach for Singleton setup, have a private _Instance and a public Instance
//Using class SingletonManager as an example:
private static SingletonManager _Instance = null;
public static SingletonManager Instance
{
get
{
if (_Instance == null)
{
//The parameter inside when true, includes inactive GameObjects
//Which is crucial because Networked GameObjects may be disabled
//Before OnStartClient()
_Instance = FindObjectOfType<SingletonManager >(true);
}
return _Instance;
}
}
Adding a Layer
Make sure to include in _Player
prefab's culling mask, Phone's Camera culling mask. If it has to deal with Player, include in OSAppPlayer
view camera also.
Last updated