728x90
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UI_Kerisdiagramm : MonoBehaviour
{
public UISprite m_SpriteCircle;
float m_CurRatio = 0.0f;
// Start is called before the first frame update
void Start()
{
StartCoroutine(Add_(0.2f, Color.red));
StartCoroutine(Add_(0.3f, Color.blue));
StartCoroutine(Add_(0.1f, Color.green));
StartCoroutine(Add_(0.2f, Color.yellow));
StartCoroutine(Add_(0.1f, Color.cyan));
StartCoroutine(Add_(0.1f, Color.gray));
}
// Update is called once per frame
void Update()
{
}
public GameObject Add(float ratio, Color color)
{
GameObject tmp = Instantiate(m_SpriteCircle.gameObject, gameObject.transform) as GameObject;
tmp.GetComponent<UISprite>().fillAmount = ratio;
tmp.GetComponent<UISprite>().color = color;
tmp.transform.rotation = Quaternion.AngleAxis(m_CurRatio * -360, Vector3.forward);
m_CurRatio += ratio;
return tmp;
}
public IEnumerator Add_(float ratio, Color color)
{
GameObject tmp = Instantiate(m_SpriteCircle.gameObject, gameObject.transform) as GameObject;
yield return null; // 생성 직후 fillamount 입력시 값이 변경 안되는 경우가 있음
tmp.GetComponent<UISprite>().fillAmount = ratio;
tmp.GetComponent<UISprite>().color = color;
tmp.transform.rotation = Quaternion.AngleAxis(m_CurRatio * -360, Vector3.forward);
m_CurRatio += ratio;
}
}
728x90
'프로그래밍 > Unity' 카테고리의 다른 글
NGUI 스크롤뷰 만들기 (0) | 2020.09.23 |
---|---|
rotate 값 360 -> 0~1 구하기 (0) | 2020.09.22 |
csv 파일 쓰기 (0) | 2020.09.08 |
Load Resources Csv & delegate & parser (0) | 2020.09.03 |
목록에 없는 API 레벨로 빌드하기 (0) | 2020.08.26 |
댓글