HandyCameraManager
A class in Root.Township, Alta.ScreenshotCamera.
Spawns and despawns each player's hand camera (the summoned screenshot camera), despawns it when the player walks too far away, and runs the streaming output. One scene instance, used through static methods; the server owns the cameras.
- Listed in Customization and screenshots
- Inherits or implements
NetworkEntityBehaviour - Nested types
CameraArguments,EffectArguments,PlayerCameraHandler
Constructors
| Member | What it is |
|---|---|
HandyCameraManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
14 private and internal fields
| Member | What it is |
|---|---|
private NetworkPrefab cameraPrefab | The hand camera prefab that gets spawned. |
private float distanceFromPlayer | How far in front of the player's head the camera spawns, in metres. |
private static HandyCameraManager instance | The scene's manager, set in Awake. |
private float maxDistanceFromPlayerSquared | Squared distance from the head beyond which the camera counts as out of range (default 9, so 3 m). |
private PositionEvent onCameraDisappearEffects | Effects played where a camera disappears. |
private PositionEvent onCameraSpawnEffects | Effects played where a camera spawns. |
private float outOfRangeHaptic | Haptic strength used to warn the player that the camera is out of range. |
private Dictionary<IPlayer, HandyCameraManager.PlayerCameraHandler> playersCameras | Server: each player's live camera handler. |
private IUnityUpdateMethod remoteDistanceCheck | Client: the registered range check update for the local player's camera, or null. |
private MethodSyncStruct<bool> requestSync | Message a client sends to ask the server to spawn or remove its camera. |
private HandCameraStreamer streamer | The streamer instance, created on first StartStreaming. |
private HandCameraStreamer streamerPrefab | Prefab for the HandCameraStreamer. |
private MethodSyncStruct<HandyCameraManager.EffectArguments> syncEffects | Message the server sends to play spawn and disappear effects. |
private float timeToDespawn | Seconds a camera may stay out of range before the server removes it. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Sets up the spawn request and effect messages. |
override void InitializeAsServer(SpawnData spawnData) | Server: creates the player to camera table. |
static void StartStreaming(RenderTexture renderTexture) | Creates the streamer from its prefab if needed and starts streaming the given render texture. |
static void StopStreaming() | Stops the streamer if one exists. |
static void UpdateCameraStatusForLocalPlayer() | Toggles the local player's camera: spawns it if they have none, otherwise removes it. Asks the server when called on a client. |
6 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Stores this as the static instance. |
private void DestroyPlayersCamera(IPlayer player) | Server: removes the player's camera handler, plays the disappear effect on clients and fades the camera out. |
private void RemoteDistanceCheck() | Client (non-host): buzzes both controllers each frame while the local player's camera is out of range. |
private void RequestSync(IPlayer player, Stream stream, bool isSpawnRequest) | Message handler. On the server, spawns or destroys the sending player's camera depending on the received flag. |
private void SpawnCameraForPlayer(IPlayer player) | Server: spawns a camera in front of the player's head (unsaved, owned by the player), fades it in and plays the spawn effect. |
private void SyncEffects(IPlayer player, Stream stream, HandyCameraManager.EffectArguments arguments) | Message handler. Client: plays the spawn or disappear effect at a position, and starts or stops the range check for the local player's camera. |