一、简单多级菜单
1、简单使用
为BIM模型提供一个结构树列表
将TreeManager.cs挂载到Controller对象
AssetViewer 物体所在的父对象
UIProject_father Canvas中Scroll View的Content
Model_updata(AssetViewer.transform.GetChild(0).gameObject, UIProject_father,0,null);
2、UI的点击事件
public void OnPointerClick(PointerEventData eventData)
{
if(eventData.button == PointerEventData.InputButton.Left)
{
if (Time.time - oldTime < 0.2f)
{
CancelInvoke("This_OnClick");
Debug.Log("双击");
}
else
{
Invoke("This_OnClick", 0.2f);
}
oldTime = Time.time;
}else if (eventData.button == PointerEventData.InputButton.Right)
{
Debug.Log("右击");
}
}
private void This_OnClick()
{
Debug.Log("单击 ");
TreeInfo treeInfo = transform.parent.GetComponent<TreeInfo>();
if (!treeInfo.Level)
{
treeManager.LevelFold(treeInfo);
}
}
缺点:
结构树的刷新需要保证 在刷新时结构树处于显示转态
或者可以使用GanvasGroup暂时隐藏
二、列表子项 同步ScrollView 滚动
TwoScrollView[1].normalizedPosition = TwoScrollView[0].normalizedPosition;
因为左侧结构树作为主树所以附树就不需要拖拉操作