using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using System; public class TaskPanelController : MonoBehaviour { [Header("Panel Information")] [SerializeField] protected GameObject _panelContent; //[SerializeField] private TaskBox TaskBoxTemplate; [SerializeField] private GameObject TaskBoxTemplate; [SerializeField] private List TaskBoxList; /// /// Fetch reference to static instance of UiManager script /// private static UIBaseManager _uiManager; private UIBaseManager UiManager { get { if (_uiManager == null) { _uiManager = FetchUiManager(); } return _uiManager; } } // TODO decide whick method use and where bind object with itself // public abstract void Bind(ManagerInterface manager); private UIBaseManager FetchUiManager() // check if need return by ref { var uiManager = GameObject.FindObjectOfType(); // uiManager.SetPanelController(gameObject); - unnecessary return uiManager; } public void InitPanelBoxes(List _tasks) { if (_panelContent == null) throw new Exception("Panel content is not attaches"); for(int i = 0; i < _tasks.Count; i++) { this.AddTask(_tasks[i]); } } protected GameObject SetupTaskBox(Task _task) { if (TaskBoxTemplate == null) throw new Exception("taskbox_template is empty"); GameObject _newTaskBox = Instantiate(TaskBoxTemplate, _panelContent.transform.position, Quaternion.identity); //.GetComponent(); _newTaskBox.transform.SetParent(_panelContent.transform); _newTaskBox.transform.localScale = new Vector3(2.5f, 2.5f, 1.0f); _newTaskBox.GetComponent().SetTask(_task); return _newTaskBox; } public void Setup(List _tasks) { this.InitPanelBoxes(_tasks); } public void AddTask(Task _task) { // update TaskManager main list of task //TaskManager.Instance.AddTask(_task); // add task to local panel contant GameObject newTaskBox = SetupTaskBox(_task); // Set new Slot instance TaskBoxList.Add(newTaskBox); } }