1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TaskCanvas : MonoBehaviour {
- public static TaskCanvas Instance;
- private void Awake()
- {
- Instance = this;
- gameObject.SetActive(false);
- }
- public Color NoColor;
- public Color OkColor;
- public GameObject BackGround = null;
- public GameObject Template;
- public List<TaskInfo> mTaskDate = new List<TaskInfo>();
- private Vector3 initBackGroundScale = Vector3.zero;
- private void Start()
- {
- initBackGroundScale = BackGround.transform.localScale;
- }
- public void CreateCanvas(List<TaskDate> pauseList)
- {
- for (int i = 0; i < pauseList.Count; i++)
- {
- // GameObject s = PrefabManager.Instance.GetPrefab("Col", Template);
- GameObject s = GameObject.Instantiate(Template, Template.transform.parent);
- s.transform.position -= new Vector3(0, i * 0.1f, 0);
- s.transform.parent = Template.transform.parent;
- s.SetActive(true);
- TaskInfo t = s.GetComponent<TaskInfo>();
- t.num.text = (i + 1).ToString();
- t.mText.text = pauseList[i].TaskName;
- t.Panel.color = pauseList[i].isOk ? OkColor : NoColor;
- mTaskDate.Add(t);
- }
- BackGround.transform.localScale = new Vector3(1,
- BackGround.transform.localScale.y + pauseList.Count * 0.35f, 1);
- }
- public void FinishTask(int index)
- {
- mTaskDate[index].Panel.color = OkColor;
- }
- public void ClearTask()
- {
- for (int i = 0; i < mTaskDate.Count; i++)
- {
- mTaskDate[i].Panel.color = NoColor;
- }
- }
- public void CloseTask()
- {
- for (int i = 0; i < mTaskDate.Count; i++)
- {
- Destroy(mTaskDate[i].gameObject);
- }
- BackGround.transform.localScale = initBackGroundScale;
- mTaskDate.Clear();
- }
-
- void Update () {
-
- }
- }
|