디자인 적용
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
namespace Gpm.Ui.Sample
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ContentSizeSetterSample : MonoBehaviour
|
||||
{
|
||||
public Entity entry;
|
||||
|
||||
public InputField input;
|
||||
public RectTransform root;
|
||||
|
||||
public void AddEntity(RectTransform parent)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
parent = root;
|
||||
}
|
||||
|
||||
Entity add = GameObject.Instantiate<Entity>(entry, parent);
|
||||
add.Init(input.text, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd7403b4893f5ba4c8de2d1cd1dc3870
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Sample/ContentSizeSetter/Scripts/Entity.cs.meta
Normal file
2
Assets/Sample/ContentSizeSetter/Scripts/Entity.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73ec133407840524993759764953e6a9
|
||||
Reference in New Issue
Block a user