var baseText = GetComponentInChildren<TextMeshProUGUI>();
texts = new List<TextMeshProUGUI>();
// 12 個の●を配置
for(int i = 0; i < CIRCLE_MAX; i++)
{
var angle = 360* i / CIRCLE_MAX;
var text = Instantiate(baseText, this.transform);
text.SetText("●");
text.fontSize = 100;
var position = Quaternion.Euler(0, 0, angle)*newVector3(0, 200, 0);
var rect = text.GetComponent<RectTransform>();
rect.localPosition = position;
texts.Add(text);
}
StartCoroutine(color());
}
IEnumerator color()
{
var hsv = ColorEx.RGBtoHSV(texts[0].color.r, texts[0].color.g, texts[0].color.b);
while(true)
{
for(int i = 0; i < CIRCLE_MAX; i++)
{
// 12 個の色相を等間隔に変化させる
int _h = hsv.H + i *(360 / CIRCLE_MAX);
if(_h >= 360)
{
_h -= 360;
}
var text = texts[i];
var rgb = ColorEx.HSVtoRGB(_h, hsv.S, hsv.V);
text.color = newColor(rgb.R, rgb.G, rgb.B, 1);
}
// 少しずつ H(色相)だけ変化させる。SV はそのまま
hsv.H += 2;
if(hsv.H>= 360)
{
hsv.H -= 360;
}
yield returnnull;
}
}
}
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class Exsample : MonoBehaviour
{
const int CIRCLE_MAX = 12;
List<TextMeshProUGUI> texts;
// Start is called before the first frame update
void Start()
{
var baseText = GetComponentInChildren<TextMeshProUGUI>();
texts = new List<TextMeshProUGUI>();
// 12 個の●を配置
for (int i = 0; i < CIRCLE_MAX; i++)
{
var angle = 360 * i / CIRCLE_MAX;
var text = Instantiate(baseText, this.transform);
text.SetText("●");
text.fontSize = 100;
var position = Quaternion.Euler(0, 0, angle) * new Vector3(0, 200, 0);
var rect = text.GetComponent<RectTransform>();
rect.localPosition = position;
texts.Add(text);
}
StartCoroutine(color());
}
IEnumerator color()
{
var hsv = ColorEx.RGBtoHSV(texts[0].color.r, texts[0].color.g, texts[0].color.b);
while (true)
{
for (int i = 0; i < CIRCLE_MAX; i++)
{
// 12 個の色相を等間隔に変化させる
int _h = hsv.H + i * (360 / CIRCLE_MAX);
if (_h >= 360)
{
_h -= 360;
}
var text = texts[i];
var rgb = ColorEx.HSVtoRGB(_h, hsv.S, hsv.V);
text.color = new Color(rgb.R, rgb.G, rgb.B, 1);
}
// 少しずつ H(色相)だけ変化させる。SV はそのまま
hsv.H += 2;
if (hsv.H >= 360)
{
hsv.H -= 360;
}
yield return null;
}
}
}
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class Exsample : MonoBehaviour
{
const int CIRCLE_MAX = 12;
List<TextMeshProUGUI> texts;
// Start is called before the first frame update
void Start()
{
var baseText = GetComponentInChildren<TextMeshProUGUI>();
texts = new List<TextMeshProUGUI>();
// 12 個の●を配置
for (int i = 0; i < CIRCLE_MAX; i++)
{
var angle = 360 * i / CIRCLE_MAX;
var text = Instantiate(baseText, this.transform);
text.SetText("●");
text.fontSize = 100;
var position = Quaternion.Euler(0, 0, angle) * new Vector3(0, 200, 0);
var rect = text.GetComponent<RectTransform>();
rect.localPosition = position;
texts.Add(text);
}
StartCoroutine(color());
}
IEnumerator color()
{
var hsv = ColorEx.RGBtoHSV(texts[0].color.r, texts[0].color.g, texts[0].color.b);
while (true)
{
for (int i = 0; i < CIRCLE_MAX; i++)
{
// 12 個の色相を等間隔に変化させる
int _h = hsv.H + i * (360 / CIRCLE_MAX);
if (_h >= 360)
{
_h -= 360;
}
var text = texts[i];
var rgb = ColorEx.HSVtoRGB(_h, hsv.S, hsv.V);
text.color = new Color(rgb.R, rgb.G, rgb.B, 1);
}
// 少しずつ H(色相)だけ変化させる。SV はそのまま
hsv.H += 2;
if (hsv.H >= 360)
{
hsv.H -= 360;
}
yield return null;
}
}
}