Scriptum/Assets/Scripts/REFACTORING/Models/Task/TaskBox.cs

52 lines
1.4 KiB
C#
Raw Normal View History

2022-06-11 23:12:52 +02:00
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;
}
}