디자인 적용
This commit is contained in:
65
Assets/Sample/ContentSizeSetter/Scripts/Entity.cs
Normal file
65
Assets/Sample/ContentSizeSetter/Scripts/Entity.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
namespace Gpm.Ui.Sample
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Entity : MonoBehaviour
|
||||
{
|
||||
public ContentSizeSetterSample control;
|
||||
|
||||
public Text valueText;
|
||||
public Text childExpand;
|
||||
|
||||
public GameObject childContainer;
|
||||
public RectTransform childRoot;
|
||||
|
||||
public void Init(string text, ContentSizeSetterSample control)
|
||||
{
|
||||
this.valueText.text = text;
|
||||
this.control = control;
|
||||
}
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
SetExpandText();
|
||||
}
|
||||
public void ChildToggle()
|
||||
{
|
||||
childContainer.SetActive(childContainer.activeSelf == false);
|
||||
|
||||
SetExpandText();
|
||||
}
|
||||
|
||||
private void SetExpandText()
|
||||
{
|
||||
if(childRoot.childCount > 0)
|
||||
{
|
||||
if (childContainer.activeSelf == true)
|
||||
{
|
||||
childExpand.text = "-";
|
||||
}
|
||||
else
|
||||
{
|
||||
childExpand.text = "+";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
childExpand.text = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddChild()
|
||||
{
|
||||
control.AddEntity(childRoot);
|
||||
|
||||
childContainer.SetActive(true);
|
||||
SetExpandText();
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
GameObject.Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user