// MIT License - Copyright (c) 2025 wallstop // Full license text: https://github.com/wallstop/unity-helpers/blob/main/LICENSE namespace Samples.UnityHelpers.UGUI.EnhancedImage { using UnityEngine; using UnityEngine.UI; using WallstopStudios.UnityHelpers.Visuals.UGUI; /// /// Creates a Canvas + EnhancedImage at runtime and applies an HDR tint. /// public sealed class EnhancedImageDemo : MonoBehaviour { [SerializeField] private Material materialTemplate; private void Start() { GameObject canvasGo = new GameObject("DemoCanvas"); Canvas canvas = canvasGo.AddComponent(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; canvasGo.AddComponent(); canvasGo.AddComponent(); GameObject imageGo = new GameObject("EnhancedImage"); imageGo.transform.SetParent(canvasGo.transform, false); EnhancedImage image = imageGo.AddComponent(); image.rectTransform.sizeDelta = new Vector2(200f, 200f); if (materialTemplate != null) { image.material = Object.Instantiate(materialTemplate); } image.HdrColor = new Color(1.6f, 1.2f, 0.8f, 1f); } } }