Skip to content

+EA 23.250 Nightly Patch 1 - Plugin.UI โ€‹

December 20, 2025

0 file modified. 1 new file created.

Important Changes โ€‹

None.

+RainbowTextColor โ€‹

File Created
cs
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

[DisallowMultipleComponent]
[RequireComponent(typeof(Text))]
public sealed class RainbowTextColor : MonoBehaviour
{
	[Header("Duration")]
	[Tooltip("่™น่‰ฒใ‚ขใƒ‹ใƒกใƒผใ‚ทใƒงใƒณใ‚’่กŒใ†็ง’ๆ•ฐ")]
	[Min(0f)]
	public float duration = 3f;

	[Header("Speed")]
	[Tooltip("1็ง’ใ‚ใŸใ‚Šไฝ•ๅ‘จHueใ‚’ๅ›žใ™ใ‹๏ผˆ1=1ๅ‘จ/็ง’๏ผ‰")]
	[Min(0f)]
	public float cyclesPerSecond = 1f;

	[Header("Look")]
	[Tooltip("ๅฝฉๅบฆ")]
	[Range(0f, 1f)]
	public float saturation = 1f;

	[Tooltip("ๆ˜Žๅบฆ")]
	[Range(0f, 1f)]
	public float value = 1f;

	[Tooltip("ๅ…ƒใฎใ‚ขใƒซใƒ•ใ‚กใซๅฏพใ—ใฆๆŽ›ใ‘ใ‚‹ไฟ‚ๆ•ฐ๏ผˆ1=ใใฎใพใพ๏ผ‰")]
	[Range(0f, 1f)]
	public float alphaMultiplier = 1f;

	[Header("Playback")]
	[Tooltip("้–‹ๅง‹ๆ™‚ใซ่‡ชๅ‹•ๅ†็”Ÿ")]
	public bool playOnEnable = true;

	[Tooltip("็ต‚ไบ†ๆ™‚ใซๅ…ƒใฎ่‰ฒใธๆˆปใ™")]
	public bool restoreOriginalColor = true;

	private Text _text;

	private Coroutine _routine;

	private Color _originalColor;

	private void Awake()
	{
		_text = GetComponent<Text>();
		_originalColor = _text.color;
	}

	private void OnEnable()
	{
		if (playOnEnable)
		{
			Play();
		}
	}

	private void OnDisable()
	{
		Stop();
		if (restoreOriginalColor && _text != null)
		{
			_text.color = _originalColor;
		}
	}

	public void Play()
	{
		if (_text == null)
		{
			_text = GetComponent<Text>();
		}
		if (!(_text == null))
		{
			_originalColor = _text.color;
			if (_routine != null)
			{
				StopCoroutine(_routine);
			}
			_routine = StartCoroutine(Run());
		}
	}

	public void Stop()
	{
		if (_routine != null)
		{
			StopCoroutine(_routine);
			_routine = null;
		}
		if (restoreOriginalColor && _text != null)
		{
			_text.color = _originalColor;
		}
	}

	private IEnumerator Run()
	{
		if (duration <= 0f)
		{
			_routine = null;
			yield break;
		}
		float elapsed = 0f;
		while (elapsed < duration)
		{
			elapsed += Time.unscaledDeltaTime;
			Color color = Color.HSVToRGB(Mathf.Repeat(elapsed * cyclesPerSecond, 1f), saturation, value);
			color.a = _originalColor.a * alphaMultiplier;
			_text.color = color;
			yield return null;
		}
		if (restoreOriginalColor)
		{
			_text.color = _originalColor;
		}
		_routine = null;
	}
}