12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Plugins.CxShine.UIUtil;
- using UnityEngine;
- public class StarComp : MonoBehaviour
- {
- public GameObject StarOnPrefab;
- public GameObject StarOffPrefab;
- private Transform _selfTr;
- private void Start()
- {
- if (_selfTr == null)
- _selfTr = gameObject.GetComponent<Transform>();
- setStar(3);
- }
- public void setStar(float value)
- {
- if (_selfTr == null)
- {
- _selfTr = gameObject.GetComponent<Transform>();
- }
- ContainerUtil.RemoveAllChild(this, _selfTr);
- for (int i = 0; i < 5; i++)
- {
- value -= 1;
- if (value >= 0)
- {
- Instantiate(StarOnPrefab, _selfTr, false);
- }
- else
- {
- Instantiate(StarOffPrefab, _selfTr, false);
- }
- }
- }
- }
|