PaintBrush
A class in Root.Township, the global namespace.
Client-side brush in the character customisation room: dip it in a colour board item, then touch the character dummy to paint that cosmetic part's primary or secondary colour.
- Listed in Global namespace: P
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
PaintBrush() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
14 private and internal fields
| Member | What it is |
|---|---|
private CosmeticColor color | Backing field for Color. |
private AltaEvent ColorApplied | Event fired after the brush changes a colour. |
private TransformSave defaultPosition | The brush's starting transform. |
private TriggerShape dippingShape | Trigger at the tip that detects colour board items and is the ray origin. |
private CharacterDummyPointer dummy | Pointer to the character dummy being painted. |
private PlayerCustomizationHandler handler | Customisation handler whose dummy's cosmetic packer is repacked after painting. |
private bool isPrimary | True paints the primary colour, false the secondary. |
private bool isSelecting | Unused flag. |
private static readonly Logger logger | NLog logger for this class. |
private CosmeticCustomizationManager manager | Cosmetic customisation manager that holds the player's cosmetics. |
private Pickup pickup | The brush's pickup. |
private float rayLength | Length of the paint ray from the tip (0.05 by default). |
private MeshRenderer tip | Renderer of the brush tip, tinted to the current colour. |
private UvRaycaster uvRaycaster | Raycaster that finds the UV coordinate hit on the dummy. |
Properties
| Member | What it is |
|---|---|
static PaintBrush Active { get; private set; } | The brush currently held, or null. |
CosmeticColor Color { get; set; } | The brush's current colour. Setting it also tints the tip material. |
Methods
11 private and internal methods
| Member | What it is |
|---|---|
private async void Apply() | Each frame, raycasts from the tip onto the dummy and recolours the cosmetic part it hits, firing ColorApplied if anything changed. |
private async Task Apply(Vector3 position, Vector3 direction, float distance) | Each frame, raycasts from the tip onto the dummy and recolours the cosmetic part it hits, firing ColorApplied if anything changed. |
private bool ApplyColor(PlayerCustomizationSlot slot) | Sets the brush colour on a cosmetic slot or part's colour arguments; returns true if something changed. |
private async Task<bool> ApplyColor(CosmeticPacker.PartId part) | Sets the brush colour on a cosmetic slot or part's colour arguments; returns true if something changed. |
private void Dipped(Collider collider) | Takes the colour from a ColorBoardItem the dipping shape touched. |
private void InteractEnded(Interactable arg1, Interactor arg2) | Clears Active and stops painting when the brush is let go. |
private void InteractStarted(Interactable arg1, Interactor arg2) | Sets Active, lifts the brush a little and starts painting when it's picked up. |
private void OnDestroy() | Cleans up the tip's material copy. |
private void OnDrawGizmos() | Draws the paint ray in the editor. |
private void Start() | Saves the start position, makes the brush kinematic, hooks pickup events and copies the tip material. |
private void Update() | Calls Apply every frame while held. |