A class in Root.Township, the global namespace.
Scales an object up when the local player comes close and down when they move away, and turns on extra behaviours while shown. Client side.
Constructors
| Member | What it is |
|---|
NearbyPlayerScaler() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
7 private and internal fields
| Member | What it is |
|---|
private float activateDistance | Distance at which the object shows. |
private Transform cachedTransform | Cached transform. |
private float deactivateDistance | Distance at which it hides again. |
private bool debugView | Inspector button flag for DebugView. |
private Behaviour[] enabledWhileActivated | Behaviours turned on only while shown. |
private float sqrdActivateDistance | activateDistance squared. |
private float sqrdDeactivateDistance | deactivateDistance squared. |
Properties
| Member | What it is |
|---|
bool? IsScalingForced { get; set; } | When set, forces shown or hidden regardless of distance. |
Events
| Member | What it is |
|---|
event Action<bool> OnNearChanged | Raised with true when the object shows and false when it hides. |
Methods
| Member | What it is |
|---|
void DebugView() | Editor button: shows the object. |
void SetScale(float progress) | Sets the scale from the curve at the given progress and toggles dock visuals. |
protected override void Awake() | Caches distances, scales to zero and turns off the linked behaviours. |
protected override void OnDisable() | Hides the object when disabled. |
3 private and internal methods
| Member | What it is |
|---|
private void LateUpdate() | Shows or hides the object by the local player's head distance, or hides it while the player is dead. |
private void OnEnable() | Sets shown or hidden right away from the current distance. |
private void Set(bool isOn) | Shows or hides with the scale animation and toggles the linked behaviours. |
Used in
Members of other types that take, return or hold a NearbyPlayerScaler: