奇怪的调
This commit is contained in:
@@ -36,35 +36,52 @@ namespace Ichni.Editor
|
||||
public Vector2 vector2;
|
||||
public void FindTab(GameElement targetElement, bool findparent = false)
|
||||
{
|
||||
if (findparent && targetElement.connectedTab != null)
|
||||
{
|
||||
targetElement.connectedTab.expandButton.onClick.Invoke();
|
||||
return;
|
||||
}
|
||||
else if (targetElement.connectedTab != null)
|
||||
{
|
||||
targetElement.connectedTab.tabButton.onClick.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
FindTab(targetElement.parentElement, true);
|
||||
if (!findparent)
|
||||
{
|
||||
targetElement.connectedTab.tabButton.onClick.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
targetElement.connectedTab.expandButton.onClick.Invoke();
|
||||
return;
|
||||
}
|
||||
//targetElement.SetUpInspector();
|
||||
StartCoroutine(TryGetTab(targetElement));
|
||||
}
|
||||
public IEnumerator TryGetTab(GameElement targetElement)
|
||||
{
|
||||
|
||||
StandardInspectionElement.GenerateForLoading();
|
||||
// 1. 向上找到最近的有Tab的祖先
|
||||
Stack<GameElement> stack = new Stack<GameElement>();
|
||||
GameElement current = targetElement;
|
||||
while (current != null && current.connectedTab == null)
|
||||
{
|
||||
stack.Push(current);
|
||||
current = current.parentElement;
|
||||
}
|
||||
HierarchyTab tab = targetElement.connectedTab;
|
||||
float Tablocalpos = (-tab.transform.localPosition.y) - (tabContainer.sizeDelta.y / 4f);
|
||||
|
||||
// 2. 如果有Tab的祖先存在,依次展开回目标
|
||||
HierarchyTab parentTab = current != null ? current.connectedTab : null;
|
||||
while (stack.Count > 0)
|
||||
{
|
||||
var elem = stack.Pop();
|
||||
// 只展开父Tab,不直接生成Tab
|
||||
if (elem.parentElement != null && elem.parentElement.connectedTab != null && !elem.parentElement.connectedTab.isExpanded)
|
||||
{
|
||||
elem.parentElement.connectedTab.ExpandOrFold();
|
||||
yield return null;
|
||||
}
|
||||
// 等待当前elem的Tab生成
|
||||
while (elem.connectedTab == null)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
parentTab = elem.connectedTab;
|
||||
}
|
||||
|
||||
// 3. 等待目标Tab实例化
|
||||
while (targetElement.connectedTab == null)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
HierarchyTab finalTab = targetElement.connectedTab;
|
||||
float Tablocalpos = (-finalTab.transform.localPosition.y) - (tabContainer.sizeDelta.y / 4f);
|
||||
float pct = Tablocalpos / tabContainer.sizeDelta.y;
|
||||
scrollRect.verticalNormalizedPosition = 1f - pct;
|
||||
finalTab.SelectGameElement();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Ichni.RhythmGame;
|
||||
using Michsky.MUIP;
|
||||
using Sirenix.Utilities;
|
||||
@@ -83,7 +84,8 @@ namespace Ichni.Editor
|
||||
}
|
||||
public void SetStatus()
|
||||
{
|
||||
expandButton.interactable = !connectedGameElement.childElementList.IsNullOrEmpty();
|
||||
//expandButton.interactable = !connectedGameElement.childElementList.IsNullOrEmpty();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,20 +126,18 @@ namespace Ichni.Editor
|
||||
EditorManager.instance.timeline.SetTimeLine(connectedGameElement);
|
||||
}
|
||||
|
||||
private void ExpandOrFold()
|
||||
public void ExpandOrFold()
|
||||
{
|
||||
this.childTabList.RemoveAll(s => s == null);
|
||||
isExpanded = !isExpanded;
|
||||
StartCoroutine(ExpandAnim());
|
||||
ExpandAnim();
|
||||
if (isExpanded)
|
||||
{
|
||||
float startTime = Time.realtimeSinceStartup;
|
||||
connectedGameElement.childElementList.Sort();//TODO: 后续可以让玩家手动快速排序
|
||||
Debug.Log("排序耗时 " + (Time.realtimeSinceStartup - startTime).ToString());
|
||||
StartCoroutine(ExpandOverTime());
|
||||
|
||||
for (var index = 0; index < connectedGameElement.childElementList.Count; index++)
|
||||
{
|
||||
var childElement = connectedGameElement.childElementList[index];
|
||||
EditorManager.instance.uiManager.hierarchy.GenerateTab(childElement, connectedGameElement);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -167,16 +167,25 @@ namespace Ichni.Editor
|
||||
EditorManager.instance.uiManager.hierarchy.tabList.Remove(this);
|
||||
}
|
||||
}
|
||||
private IEnumerator ExpandAnim()
|
||||
private void ExpandAnim()
|
||||
{
|
||||
expandButton.transform.DORotate(new Vector3(0, 0, !isExpanded ? 0f : 180f), 0.2f);
|
||||
}
|
||||
private IEnumerator ExpandOverTime()//帧率过低的时候等一下再实例化
|
||||
{
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
float startTime = Time.realtimeSinceStartup;
|
||||
for (var index = 0; index < connectedGameElement.childElementList.Count; index++)
|
||||
{
|
||||
expandButton.transform.GetComponentInChildren<TMP_Text>().rectTransform.localRotation =
|
||||
Quaternion.Euler(0, 0, isExpanded ? 18 * i : 180 - 18 * i);
|
||||
yield return null;
|
||||
int hasYield = 0;
|
||||
while (Time.realtimeSinceStartup - startTime > 1f / EditorManager.instance.editorSettings.frameRate * 3f && hasYield <= 2)
|
||||
{
|
||||
yield return null;
|
||||
hasYield += 1;
|
||||
}
|
||||
var childElement = connectedGameElement.childElementList[index];
|
||||
EditorManager.instance.uiManager.hierarchy.GenerateTab(childElement, connectedGameElement);
|
||||
}
|
||||
expandButton.transform.GetComponentInChildren<TMP_Text>().rectTransform.localRotation = Quaternion.Euler(0, 0, isExpanded ? 180 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using UnityEngine;
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public static class StandardInspectionElement
|
||||
{
|
||||
private static IHaveInspection inspector => EditorManager.instance.uiManager.inspector;
|
||||
private static Inspector inspectorUI => EditorManager.instance.uiManager.inspector;
|
||||
public static void GenerateForTransform(GameElement gameElement, DynamicUIContainer generateContainer = null)//关于有Transform
|
||||
{
|
||||
if (generateContainer is null)
|
||||
{
|
||||
generateContainer = inspector.GenerateContainer("Generate Elements");
|
||||
}
|
||||
var animationSubcontainer = generateContainer.GenerateSubcontainer(3);
|
||||
var displacementButton = inspector.GenerateButton(gameElement, animationSubcontainer, "Displacement", () =>
|
||||
{
|
||||
Displacement.GenerateElement("New Displacement", Guid.NewGuid(), new List<string>(), true, gameElement,
|
||||
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
|
||||
}); //位移
|
||||
|
||||
var swirlButton = inspector.GenerateButton(gameElement, animationSubcontainer, "Swirl", () =>
|
||||
{
|
||||
Swirl.GenerateElement("New Swirl", Guid.NewGuid(), new List<string>(), true, gameElement,
|
||||
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
|
||||
}); //旋转
|
||||
var scaleButton = inspector.GenerateButton(gameElement, animationSubcontainer, "Scale", () =>
|
||||
{
|
||||
Scale.GenerateElement("New Scale", Guid.NewGuid(), new List<string>(), true, gameElement,
|
||||
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
|
||||
}); //缩放
|
||||
}
|
||||
public static void GenerateForLoading()
|
||||
{
|
||||
inspectorUI.ClearInspector();
|
||||
var container = inspector.GenerateContainer("Loading");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97779e95563721b4e8d4a28bb0d46cb9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user