Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

50 行
1.2 KiB

using UnityEngine.UI;
namespace UnityEngine.Rendering.UI
{
[ExecuteAlways]
public class UIFoldout : Toggle
{
public GameObject content;
public GameObject arrowOpened;
public GameObject arrowClosed;
protected override void Start()
{
base.Start();
onValueChanged.AddListener(SetState);
SetState(isOn);
}
#pragma warning disable 108,114
void OnValidate()
{
SetState(isOn, false);
}
#pragma warning restore 108,114
public void SetState(bool state)
{
SetState(state, true);
}
public void SetState(bool state, bool rebuildLayout)
{
if (arrowOpened == null || arrowClosed == null || content == null)
return;
if (arrowOpened.activeSelf != state)
arrowOpened.SetActive(state);
if (arrowClosed.activeSelf == state)
arrowClosed.SetActive(!state);
if (content.activeSelf != state)
content.SetActive(state);
if (rebuildLayout)
LayoutRebuilder.ForceRebuildLayoutImmediate(transform.parent as RectTransform);
}
}
}