A class in Root.Township, Alta.Utilities.
Client: pooled floating text that drifts upward, faces the local player's head and scales with distance. It switches itself off beyond maxDistance and back on when the player comes close. DamagePopup extends it.
Constructors
| Member | What it is |
|---|
TextPopup() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
5 private and internal fields
| Member | What it is |
|---|
private LocomotionController locomotionController | The local player's locomotion controller, used to detect when they come back in range. |
private float maxDistance | Squared distance beyond which the popup stops updating. Set as 10 metres in the inspector. |
private AnimationCurve scaleBasedOnDistance | Curve mapping distance to the head onto the popup's scale. |
private Text text | UI text component that shows the message. |
private float upSpeed | How fast the popup rises, in metres per second. |
Properties
| Member | What it is |
|---|
PooledObject PooledObject { get; set; } | The pooled object this popup belongs to. The popup stops updating once it is released. |
1 private and internal property
| Member | What it is |
|---|
private Transform LocalPlayerHead { get; set; } | The local player's head transform the popup faces. |
Methods
| Member | What it is |
|---|
void UpdateText(string textToDisplay) | Sets the text, in red unless a colour is given. |
void UpdateText(string textToDisplay, Color color) | Sets the text, in red unless a colour is given. |
5 private and internal methods
| Member | What it is |
|---|
private void Awake() | Gets the pooled object and the local player's head, and hooks local player changes. |
private void CheckEnabled(PlayerController player, Vector3 oldPosition, Vector3 newPosition, LocomotionFunction function) | Locomotion handler: re-enables the popup once the player moves within range. |
private void OnDestroy() | Unhooks the locomotion and local player events. |
private void Update() | Moves the text up, turns it to face the head and scales it, or disables itself when the player is too far. |
private void UpdateHead(PlayerController player) | Takes the head and locomotion controller of a newly set local player. |
Used in
Members of other types that take, return or hold a TextPopup: