// AvatarPaint.cs // Paint buckets for avatars: click a colour button and your whole avatar (body, clothes, hair, everything you wear) // turns that colour, as if you were dipped in paint. The reset button makes you look normal again. Everybody sees it, // also players who join later. It lasts until you reset it, leave the world, or the scene changes. // // Set up: slot any objects as the buttons (they become clickable). Nine colour buttons (red, orange, yellow, green, // blue, indigo, violet, white, black; change any colour in the Inspector) and a reset button. Leave out the ones you // do not need. Strength: how solid the paint is (1 = solid colour, lower lets the outfit show through). // Glow: above 0, the paint also glows in its colour (1 = full brightness). using IHXR.Simulation; public class AvatarPaint : ScriptBase { protected override bool SyncTransformStateByDefault => false; public SceneObject RedButton; public Color Red = new Color(0.9f, 0.1f, 0.1f); public SceneObject OrangeButton; public Color Orange = new Color(1f, 0.5f, 0.05f); public SceneObject YellowButton; public Color Yellow = new Color(1f, 0.9f, 0.1f); public SceneObject GreenButton; public Color Green = new Color(0.1f, 0.75f, 0.2f); public SceneObject BlueButton; public Color Blue = new Color(0.1f, 0.35f, 0.95f); public SceneObject IndigoButton; public Color Indigo = new Color(0.3f, 0.1f, 0.7f); public SceneObject VioletButton; public Color Violet = new Color(0.65f, 0.2f, 0.9f); public SceneObject WhiteButton; public Color White = new Color(1f, 1f, 1f); public SceneObject BlackButton; public Color Black = new Color(0.03f, 0.03f, 0.03f); [Tooltip("Makes the player who clicks it look normal again.")] public SceneObject ResetButton; [Tooltip("How solid the paint is: 1 = solid colour, lower lets the outfit show through.")] [Range(0f, 1f)] public float Strength = 0.8f; [Tooltip("0 = no glow; above 0 the paint glows in its colour (1 = full brightness, up to 10).")] public float Glow = 0f; public override void Start() { Paint(RedButton, "Red paint", () => Red); Paint(OrangeButton, "Orange paint", () => Orange); Paint(YellowButton, "Yellow paint", () => Yellow); Paint(GreenButton, "Green paint", () => Green); Paint(BlueButton, "Blue paint", () => Blue); Paint(IndigoButton, "Indigo paint", () => Indigo); Paint(VioletButton, "Violet paint", () => Violet); Paint(WhiteButton, "White paint", () => White); Paint(BlackButton, "Black paint", () => Black); if (IsValid(ResetButton)) MakeInteractable(ResetButton, info => ResetPlayerTint(info.Username), true, null, true, 10f, "Wash the paint off"); } // A colour button: whoever clicks it is painted that colour. private void Paint(SceneObject button, string hint, System.Func colour) { if (IsValid(button)) MakeInteractable(button, info => TintPlayer(info.Username, colour(), Strength, Glow), true, null, true, 10f, hint); } private bool IsValid(SceneObject o) => o != null && !o.IsNull; }