Inspector
初步测试Inspector
This commit is contained in:
@@ -10,12 +10,12 @@ namespace Ichni.Editor
|
||||
public partial class HierarchyTab : MonoBehaviour
|
||||
{
|
||||
public GameObject indentationLinePrefab;
|
||||
|
||||
|
||||
public GameElement connectedGameElement;
|
||||
public HierarchyTab parentTab;
|
||||
public List<HierarchyTab> childTabList;
|
||||
public List<int> IDqueue;
|
||||
|
||||
|
||||
public int tabLayer;
|
||||
public bool isSelected;
|
||||
public bool isExpanded;
|
||||
@@ -27,12 +27,11 @@ namespace Ichni.Editor
|
||||
public Button expandButton;
|
||||
public Button gotoButton;
|
||||
public TMP_Text tabButtonText;
|
||||
public Hierarchy hierarchy;
|
||||
|
||||
public void SetTab(GameElement targetElement, GameElement parentElement)
|
||||
{
|
||||
|
||||
connectedGameElement=targetElement;
|
||||
|
||||
connectedGameElement = targetElement;
|
||||
tabButtonText.text = targetElement.elementName;
|
||||
targetElement.connectedTab = this;
|
||||
this.isExpanded = false;
|
||||
@@ -44,13 +43,15 @@ namespace Ichni.Editor
|
||||
this.tabLayer = 0;
|
||||
this.parentTab = null;
|
||||
this.transform.SetAsLastSibling();
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
this.parentTab = parentElement.connectedTab;
|
||||
parentElement.connectedTab.childTabList.Add(this);
|
||||
this.tabLayer = this.parentTab.tabLayer + 1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.transform.SetSiblingIndex(this.parentTab.transform.GetSiblingIndex() +
|
||||
this.parentTab.connectedGameElement.childElementList.Count);
|
||||
|
||||
@@ -66,11 +67,12 @@ namespace Ichni.Editor
|
||||
Instantiate(indentationLinePrefab, tabRect).GetComponent<RectTransform>().anchoredPosition = new Vector2(lineX, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
float posX = -5 + 30 * tabLayer;
|
||||
tabMainRect.anchoredPosition = new Vector2(posX, tabMainRect.anchoredPosition.y);
|
||||
|
||||
tabButton.onClick.AddListener(SelectGameElement);
|
||||
expandButton.onClick.AddListener(ExpandOrFold);
|
||||
}
|
||||
}
|
||||
@@ -88,48 +90,53 @@ namespace Ichni.Editor
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
private void SelectGameElement()
|
||||
{
|
||||
EditorManager.instance.uiManager.inspector.connectedGameElement = connectedGameElement;
|
||||
connectedGameElement.SetUpInspector();
|
||||
}
|
||||
|
||||
private void ExpandOrFold()
|
||||
{
|
||||
this.childTabList.RemoveAll(s => s == null);
|
||||
isExpanded=!isExpanded;
|
||||
isExpanded = !isExpanded;
|
||||
|
||||
if(isExpanded){
|
||||
expandButton.transform.Rotate(new Vector3(0,0,180));
|
||||
foreach(GameElement i in connectedGameElement.childElementList){
|
||||
HierarchyTab a=hierarchy.GenerateTab(i,connectedGameElement);
|
||||
if (isExpanded)
|
||||
{
|
||||
expandButton.transform.Rotate(new Vector3(0, 0, 180));
|
||||
foreach (GameElement i in connectedGameElement.childElementList)
|
||||
{
|
||||
HierarchyTab a = EditorManager.instance.uiManager.hierarchy.GenerateTab(i, connectedGameElement);
|
||||
childTabList.Add(a);
|
||||
}
|
||||
}else{
|
||||
expandButton.transform.Rotate(new Vector3(0,0,180));
|
||||
}
|
||||
else
|
||||
{
|
||||
expandButton.transform.Rotate(new Vector3(0, 0, 180));
|
||||
|
||||
for (int i = childTabList.Count-1; i>=0; i--)
|
||||
for (int i = childTabList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
childTabList[i].SetExpansion(isExpanded);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SetExpansion(bool expand)
|
||||
{
|
||||
if (!expand&&isExpanded)
|
||||
if (!expand && isExpanded)
|
||||
{
|
||||
foreach (var tab in childTabList)
|
||||
{
|
||||
tab.SetExpansion(expand);//false
|
||||
tab.SetExpansion(expand); //false
|
||||
}
|
||||
}
|
||||
|
||||
if (!expand)
|
||||
{
|
||||
parentTab.childTabList.Remove(this);
|
||||
Destroy(gameObject);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user