using UnityEngine; [ExecuteAlways] public class AdjustableGlowOrb : MonoBehaviour { [SerializeField] private Color glowColor = new Color(0.1f, 0.65f, 1f, 1f); [SerializeField, Min(0f)] private float emissionIntensity = 2.5f; [SerializeField] private Renderer targetRenderer; private MaterialPropertyBlock propertyBlock; private void OnEnable() { ApplyVisuals(); } private void OnValidate() { ApplyVisuals(); } public void SetGlowColor(Color color) { glowColor = color; ApplyVisuals(); } public Color GetGlowColor() => glowColor; private void ApplyVisuals() { if (targetRenderer == null) { targetRenderer = GetComponent(); } if (targetRenderer == null) { return; } propertyBlock ??= new MaterialPropertyBlock(); targetRenderer.GetPropertyBlock(propertyBlock); Color emission = glowColor * emissionIntensity; propertyBlock.SetColor("_BaseColor", glowColor); propertyBlock.SetColor("_Color", glowColor); propertyBlock.SetColor("_EmissionColor", emission); targetRenderer.SetPropertyBlock(propertyBlock); } }