暂时存档
Timeline WindowAnim不止window能用
This commit is contained in:
@@ -50,7 +50,7 @@ namespace Ichni.Editor
|
||||
parentElement.connectedTab.childTabList.Add(this);
|
||||
this.tabLayer = this.parentTab.tabLayer + 1;
|
||||
this.transform.SetSiblingIndex(this.parentTab.transform.GetSiblingIndex() + GetAllChildrenCount(this.parentTab));
|
||||
|
||||
|
||||
if (!this.parentTab.isExpanded)
|
||||
{
|
||||
this.isExpanded = false;
|
||||
@@ -91,6 +91,7 @@ namespace Ichni.Editor
|
||||
{
|
||||
EditorManager.instance.operationManager.SelectElement(connectedGameElement);
|
||||
EditorManager.instance.uiManager.inspector.SetInspector(connectedGameElement);
|
||||
EditorManager.instance.timeline.SetTimeLine(connectedGameElement);
|
||||
}
|
||||
|
||||
private void ExpandOrFold()
|
||||
@@ -101,7 +102,7 @@ namespace Ichni.Editor
|
||||
if (isExpanded)
|
||||
{
|
||||
expandButton.transform.Rotate(new Vector3(0, 0, 180));
|
||||
|
||||
|
||||
for (var index = 0; index < connectedGameElement.childElementList.Count; index++)
|
||||
{
|
||||
var childElement = connectedGameElement.childElementList[index];
|
||||
@@ -123,9 +124,9 @@ namespace Ichni.Editor
|
||||
{
|
||||
if (!expand && isExpanded)
|
||||
{
|
||||
for(int i=childTabList.Count;i>0;i--)
|
||||
for (int i = childTabList.Count; i > 0; i--)
|
||||
{
|
||||
childTabList[i-1].SetExpansion(expand); //false
|
||||
childTabList[i - 1].SetExpansion(expand); //false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,14 @@ namespace Ichni.Editor
|
||||
|
||||
public void Initialize(IBaseElement baseElement, string title, string parameterName)
|
||||
{
|
||||
transform.localScale = Vector3.zero;
|
||||
this.connectedBaseElement = baseElement;
|
||||
this.parameterName = parameterName;
|
||||
this.title.text = title;
|
||||
unitList = new List<DynamicUICompositeUnit>();
|
||||
closeButton.onClick.AddListener(() =>
|
||||
{
|
||||
ApplyParameters();
|
||||
Destroy(gameObject);
|
||||
});
|
||||
closeButton.onClick.AddListener(Quit);
|
||||
|
||||
StartCoroutine(WindowAnim.ShowPanel(gameObject));
|
||||
}
|
||||
|
||||
public void RemoveUnit(DynamicUICompositeUnit unit)
|
||||
@@ -47,9 +46,9 @@ namespace Ichni.Editor
|
||||
unitList.Add(unit);
|
||||
unit.SetUnit(this, content);
|
||||
}
|
||||
|
||||
|
||||
unitPrefab = EditorManager.instance.basePrefabs.stringUnit;
|
||||
|
||||
|
||||
//初始化:获取当前的List<string>,并生成对应的Unit
|
||||
List<string> list = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as List<string>;
|
||||
foreach (string item in list)
|
||||
@@ -57,14 +56,14 @@ namespace Ichni.Editor
|
||||
GenerateUnit(item);
|
||||
}
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
|
||||
|
||||
//为添加新的Unit的按钮设置点击事件
|
||||
addNewUnitButton.onClick.AddListener(() =>
|
||||
{
|
||||
GenerateUnit("");
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
});
|
||||
|
||||
|
||||
//将当前所有Unit的值应用到对应的变量中
|
||||
ApplyParameters = () =>
|
||||
{
|
||||
@@ -86,22 +85,22 @@ namespace Ichni.Editor
|
||||
unitList.Add(unit);
|
||||
unit.SetUnit(this, content);
|
||||
}
|
||||
|
||||
|
||||
unitPrefab = EditorManager.instance.basePrefabs.animatedFloatUnit;
|
||||
|
||||
|
||||
FlexibleFloat flexibleFloat = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as FlexibleFloat;
|
||||
foreach (AnimatedFloat animatedFloat in flexibleFloat.animations)
|
||||
{
|
||||
GenerateUnit(animatedFloat);
|
||||
}
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
|
||||
|
||||
addNewUnitButton.onClick.AddListener(() =>
|
||||
{
|
||||
GenerateUnit(new AnimatedFloat(0, 0, 0, 0, AnimationCurveType.Linear));
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
});
|
||||
|
||||
|
||||
ApplyParameters = () =>
|
||||
{
|
||||
FlexibleFloat newFlexibleFloat = new FlexibleFloat();
|
||||
@@ -121,22 +120,22 @@ namespace Ichni.Editor
|
||||
unitList.Add(unit);
|
||||
unit.SetUnit(this, content);
|
||||
}
|
||||
|
||||
|
||||
unitPrefab = EditorManager.instance.basePrefabs.animatedIntUnit;
|
||||
|
||||
|
||||
FlexibleInt flexibleInt = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as FlexibleInt;
|
||||
foreach (AnimatedInt animatedInt in flexibleInt.animations)
|
||||
{
|
||||
GenerateUnit(animatedInt);
|
||||
}
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
|
||||
|
||||
addNewUnitButton.onClick.AddListener(() =>
|
||||
{
|
||||
GenerateUnit(new AnimatedInt(0, 0));
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
});
|
||||
|
||||
|
||||
ApplyParameters = () =>
|
||||
{
|
||||
FlexibleInt newFlexibleInt = new FlexibleInt();
|
||||
@@ -156,7 +155,7 @@ namespace Ichni.Editor
|
||||
unitList.Add(unit);
|
||||
unit.SetUnit(this, content);
|
||||
}
|
||||
|
||||
|
||||
unitPrefab = EditorManager.instance.basePrefabs.animatedBoolUnit;
|
||||
FlexibleBool flexibleBool = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as FlexibleBool;
|
||||
foreach (AnimatedBool animatedBool in flexibleBool.animations)
|
||||
@@ -164,13 +163,13 @@ namespace Ichni.Editor
|
||||
GenerateUnit(animatedBool);
|
||||
}
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
|
||||
|
||||
addNewUnitButton.onClick.AddListener(() =>
|
||||
{
|
||||
GenerateUnit(new AnimatedBool(0, false));
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
});
|
||||
|
||||
|
||||
ApplyParameters = () =>
|
||||
{
|
||||
FlexibleBool newFlexibleBool = new FlexibleBool();
|
||||
@@ -181,5 +180,12 @@ namespace Ichni.Editor
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, newFlexibleBool);
|
||||
};
|
||||
}
|
||||
public void Quit()
|
||||
{
|
||||
ApplyParameters();
|
||||
//StartCoroutine(WindowAnim.HidePanel(gameObject, true));
|
||||
Destroy(gameObject);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,20 +10,25 @@ namespace Ichni.Editor
|
||||
public GameElement connectedGameElement;
|
||||
public RectTransform WindowRect { get; set; }
|
||||
public List<DynamicUIContainer> Containers { get; set; }
|
||||
|
||||
|
||||
public void Initialize(GameElement gameElement, string title)
|
||||
{
|
||||
StartCoroutine(WindowAnim.ShowPanel(gameObject));
|
||||
WindowRect = windowRect;
|
||||
Containers = new List<DynamicUIContainer>();
|
||||
|
||||
|
||||
connectedGameElement = gameElement;
|
||||
this.title.text = title;
|
||||
closeButton.onClick.AddListener(() =>
|
||||
{
|
||||
Destroy(gameObject);
|
||||
});
|
||||
closeButton.onClick.AddListener(Quit);
|
||||
|
||||
}
|
||||
public void Quit()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
//StartCoroutine(WindowAnim.HidePanel(gameObject, true));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -12,15 +12,15 @@ namespace Ichni.Editor
|
||||
{
|
||||
private Timeline timeline => EditorManager.instance.uiManager.timeline;
|
||||
private SongInformation songInformation => EditorManager.instance.songInformation;
|
||||
|
||||
|
||||
public GameObject timePointerPrefab;
|
||||
public List<TimePointer> timePointerList;
|
||||
|
||||
|
||||
public RectTransform timePointerArea;
|
||||
public RectTransform visibleTimePointerArea;
|
||||
|
||||
|
||||
public RectTransform mainTimePointer;
|
||||
|
||||
|
||||
public float intervalUnit;
|
||||
public float timePointerInterval;
|
||||
public float sizeNegative, sizePositive;
|
||||
@@ -29,7 +29,7 @@ namespace Ichni.Editor
|
||||
/// delay时间区间中,(-delay, 0)的距离偏移量
|
||||
/// </summary>
|
||||
public float delayDistanceOffset;
|
||||
|
||||
|
||||
public float leftSideSongTime, rightSideSongTime, songTimeDistance;
|
||||
|
||||
private void Start()
|
||||
@@ -62,20 +62,20 @@ namespace Ichni.Editor
|
||||
/// <param name="delay"></param>
|
||||
/// <param name="bpm"></param>
|
||||
public void Initialize(float delay, float bpm)
|
||||
{
|
||||
{
|
||||
timePointerInterval = 30;
|
||||
ClearPointers();
|
||||
|
||||
|
||||
int beatDivider = 1;
|
||||
|
||||
|
||||
intervalUnit = (60f / bpm) / beatDivider * 1000;
|
||||
|
||||
|
||||
sizeNegative = delay * beatDivider / timeline.timePerBeat;
|
||||
sizePositive = songInformation.song.length * beatDivider / timeline.timePerBeat;
|
||||
|
||||
|
||||
negativePointerAmount = Mathf.CeilToInt(sizeNegative);
|
||||
positivePointerAmount = Mathf.CeilToInt(sizePositive);
|
||||
|
||||
|
||||
totalPointerAmount = negativePointerAmount + positivePointerAmount;
|
||||
|
||||
timePointerArea.sizeDelta = new Vector2(timePointerInterval * (sizeNegative + sizePositive), 60f);
|
||||
@@ -90,12 +90,12 @@ namespace Ichni.Editor
|
||||
{
|
||||
CreatePointer(beatDivider, i);
|
||||
}
|
||||
|
||||
|
||||
//ChangeSongTimeDistance(0);
|
||||
SetRange(timeline.beatmapStartTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public partial class TimePointerModule
|
||||
{
|
||||
/// <summary>
|
||||
@@ -115,7 +115,7 @@ namespace Ichni.Editor
|
||||
leftSideSongTime = startTime - songTimeDistance * proportion;
|
||||
rightSideSongTime = startTime + songTimeDistance * (1 - proportion);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成指示线
|
||||
/// </summary>
|
||||
@@ -132,13 +132,16 @@ namespace Ichni.Editor
|
||||
|
||||
pointer.time = index * intervalUnit / 1000f;
|
||||
pointer.intervalUnitText.text = Mathf.RoundToInt(index * intervalUnit).ToString();
|
||||
|
||||
if (beatDivider > 1)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新指示线位置
|
||||
/// </summary>
|
||||
private void UpdatePointers()
|
||||
public void UpdatePointers()
|
||||
{
|
||||
delayDistanceOffset = timePointerInterval * (negativePointerAmount - sizeNegative);
|
||||
timePointerArea.sizeDelta = new Vector2(timePointerInterval * totalPointerAmount, 55f);
|
||||
@@ -149,7 +152,7 @@ namespace Ichni.Editor
|
||||
new Vector2((pointer.index + negativePointerAmount) * timePointerInterval + 15f - delayDistanceOffset, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 清楚所有指示线
|
||||
/// </summary>
|
||||
@@ -161,7 +164,7 @@ namespace Ichni.Editor
|
||||
}
|
||||
timePointerList.Clear();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 缩放时间线的展示时间宽度
|
||||
/// </summary>
|
||||
|
||||
@@ -1,18 +1,119 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.RhythmGame;
|
||||
using Sirenix.Utilities;
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class Timeline : MonoBehaviour
|
||||
public partial class Timeline : MonoBehaviour
|
||||
{
|
||||
public float songTime => EditorManager.instance.songInformation.songTime;
|
||||
public float songBeat => EditorManager.instance.songInformation.songBeat;
|
||||
public float beatmapStartTime => -EditorManager.instance.songInformation.delay;
|
||||
public float timePerBeat => 60f / EditorManager.instance.songInformation.bpm;
|
||||
|
||||
|
||||
|
||||
|
||||
public GameObject timelineTabRect;
|
||||
public TimePointerModule timePointerModule;
|
||||
public MusicPlayer musicPlayer;
|
||||
|
||||
|
||||
public TMP_InputField TimeField;
|
||||
public TMP_InputField BeatField;
|
||||
|
||||
public RectTransform GetinputArea;
|
||||
public void Update()
|
||||
{
|
||||
if (musicPlayer.isPlaying) UpdateTime();
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(GetinputArea, Mouse.current.position.ReadValue()))
|
||||
{
|
||||
|
||||
DetectSetRange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
private void DetectSetRange()
|
||||
{
|
||||
if (Mouse.current.scroll.ReadValue().y != 0)
|
||||
{
|
||||
|
||||
if (Keyboard.current.leftCtrlKey.isPressed || Keyboard.current.rightCtrlKey.isPressed)
|
||||
{
|
||||
float scrollValue = Mouse.current.scroll.ReadValue().y / 12;
|
||||
if (timePointerModule.timePointerInterval + scrollValue >= 30)
|
||||
{
|
||||
timePointerModule.timePointerInterval += scrollValue;
|
||||
timePointerModule.UpdatePointers();
|
||||
timePointerModule.SetRange(songTime);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Mouse.current.scroll.ReadValue().y >= 0)
|
||||
{
|
||||
SetTime((EditorManager.instance.songInformation.songTime + timePerBeat).ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EditorManager.instance.songInformation.songTime - timePerBeat >= 0)
|
||||
SetTime((EditorManager.instance.songInformation.songTime - timePerBeat).ToString());
|
||||
else
|
||||
SetTime("0");
|
||||
|
||||
}
|
||||
UpdateTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void UpdateTime()
|
||||
{
|
||||
TimeField.text = songTime.ToString("F2");
|
||||
BeatField.text = songBeat.ToString("F2");
|
||||
}
|
||||
|
||||
public void SetTime(string time)
|
||||
{
|
||||
musicPlayer.PauseMusic();
|
||||
musicPlayer.audioSource.time = float.Parse(time);
|
||||
EditorManager.instance.songInformation.songTime = float.Parse(time);
|
||||
|
||||
timePointerModule.UpdatePointers();
|
||||
timePointerModule.SetRange(songTime);
|
||||
|
||||
}
|
||||
public void SetBeat(string beat)
|
||||
{
|
||||
musicPlayer.PauseMusic();
|
||||
musicPlayer.audioSource.time = float.Parse(beat) * timePerBeat;
|
||||
EditorManager.instance.songInformation.songTime = float.Parse(beat) * timePerBeat;
|
||||
|
||||
timePointerModule.UpdatePointers();
|
||||
timePointerModule.SetRange(songTime);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public partial class Timeline
|
||||
{
|
||||
public TimelineTab timelineTabPrefab;
|
||||
public Dictionary<Type, TimelineTab> timelineTabList = new Dictionary<Type, TimelineTab>();
|
||||
public void SetTimeLine(GameElement element)
|
||||
{
|
||||
//在做了
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
23
Assets/Scripts/DynamicUI/Timeline/TimelineTab.cs
Normal file
23
Assets/Scripts/DynamicUI/Timeline/TimelineTab.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class TimelineTab : MonoBehaviour
|
||||
{
|
||||
public TMP_Text Title;
|
||||
public GameElement connectedGameElement;
|
||||
public List<GameElement> GelementPointer;
|
||||
public void SetTab(GameElement element, Type DisplayType)
|
||||
{
|
||||
connectedGameElement = element;
|
||||
Title.text = DisplayType.ToString();
|
||||
foreach (var i in element.childElementList) if (i.GetType() == DisplayType) GelementPointer.Add(i);
|
||||
}
|
||||
public void AddElement(GameElement gameElement)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/DynamicUI/Timeline/TimelineTab.cs.meta
Normal file
11
Assets/Scripts/DynamicUI/Timeline/TimelineTab.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2508d5efc83bb294aa25a45eb1d2f59d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
45
Assets/Scripts/DynamicUI/WindowAnim.cs
Normal file
45
Assets/Scripts/DynamicUI/WindowAnim.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class WindowAnim
|
||||
{
|
||||
public static IEnumerator ShowPanel(GameObject gameObject)
|
||||
{
|
||||
AnimationCurve animationCurve = new AnimationCurve(
|
||||
new Keyframe(0, 0),
|
||||
new Keyframe(0.25f, 0.55f),
|
||||
new Keyframe(0.5f, 0.85f),
|
||||
new Keyframe(0.75f, 0.97f),
|
||||
new Keyframe(1, 1)
|
||||
);
|
||||
float timer = 0;
|
||||
while (timer <= 1)
|
||||
{
|
||||
gameObject.transform.localScale = Vector3.one * animationCurve.Evaluate(timer);
|
||||
timer += Time.deltaTime * 5f;
|
||||
yield return null;
|
||||
}
|
||||
gameObject.transform.localScale = Vector3.one;
|
||||
}
|
||||
public static IEnumerator HidePanel(GameObject gameObject, bool DestoryOrNot = false)
|
||||
{
|
||||
AnimationCurve animationCurve = new AnimationCurve(
|
||||
new Keyframe(0, 0),
|
||||
new Keyframe(0.25f, 0.55f),
|
||||
new Keyframe(0.5f, 0.85f),
|
||||
new Keyframe(0.75f, 0.97f),
|
||||
new Keyframe(1, 1)
|
||||
);
|
||||
float timer = 1;
|
||||
while (timer >= 0)
|
||||
{
|
||||
gameObject.transform.localScale = Vector3.one * animationCurve.Evaluate(timer);
|
||||
timer += Time.deltaTime * 5f;
|
||||
yield return null;
|
||||
}
|
||||
gameObject.transform.localScale = Vector3.zero;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/DynamicUI/WindowAnim.cs.meta
Normal file
11
Assets/Scripts/DynamicUI/WindowAnim.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4e9f7cedbb8ef246b2a3920b1ce4402
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user