Scriptum/Assets/Scripts/REFACTORING/Models/Task/TaskBox.cs
2022-11-06 20:46:25 +01:00

52 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TaskBox : MonoBehaviour
{
[Header("Task Box Template")]
[SerializeField] private GameObject taskBox_header;
[SerializeField] private GameObject taskBox_body;
[Header("Task Box Content")]
[SerializeField] private GameObject title;
[SerializeField] private GameObject content;
[SerializeField] public Task task;
public void Update()
{
RectTransform rt = gameObject.GetComponent<RectTransform>();
//rt.sizeDelta = new Vector2(100, 100);
if(taskBox_body.active)
{
rt.sizeDelta = new Vector2(rt.sizeDelta.x, taskBox_header.GetComponent<RectTransform>().sizeDelta.y + taskBox_body.GetComponent<RectTransform>().sizeDelta.y);
}
if(!taskBox_body.active)
{
rt.sizeDelta = new Vector2(rt.sizeDelta.x, taskBox_header.GetComponent<RectTransform>().sizeDelta.y);
}
}
public void SetTask(Task _task)
{
this.task = _task;
this.SetTitle(_task.Title);
this.SetContent(_task.Description);
}
private void SetTitle(string _title)
{
this.title.GetComponent<TMPro.TextMeshProUGUI>().text = _title;
}
private void SetContent(string _content)
{
this.content.GetComponent<TMPro.TextMeshProUGUI>().text = _content;
}
}