From 45d87738658bcc798eacc7fdeed8b4d6fab0b8a3 Mon Sep 17 00:00:00 2001 From: js6pak Date: Sat, 9 Jan 2021 20:09:25 +0100 Subject: [PATCH] Add SetOutline extension --- Reactor/Extensions/Extensions.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Reactor/Extensions/Extensions.cs b/Reactor/Extensions/Extensions.cs index f0ecf6c..4c36611 100644 --- a/Reactor/Extensions/Extensions.cs +++ b/Reactor/Extensions/Extensions.cs @@ -97,5 +97,23 @@ namespace Reactor.Extensions return task.Task; } + + private static readonly int _outline = Shader.PropertyToID("_Outline"); + private static readonly int _outlineColor = Shader.PropertyToID("_OutlineColor"); + private static readonly int _addColor = Shader.PropertyToID("_AddColor"); + + /// + /// Sets color outline for renderers using default Among Us shader + /// + public static void SetOutline(this Renderer renderer, Color? color) + { + renderer.material.SetFloat(_outline, color.HasValue ? 1 : 0); + + if (color.HasValue) + { + renderer.material.SetColor(_outlineColor, color.Value); + renderer.material.SetColor(_addColor, color.Value); + } + } } }