自定义曲线编辑器, Trail界面跟进
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.RhythmGame;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class DynamicUICustomCurveKeyframeUnit : DynamicUICompositeUnit
|
||||
{
|
||||
public TMP_InputField timeInputField;
|
||||
public TMP_InputField valueInputField;
|
||||
public TMP_InputField inTangentInputField;
|
||||
public TMP_InputField outTangentInputField;
|
||||
|
||||
public override void SetUnit(CompositeParameterWindow window, object itemContent)
|
||||
{
|
||||
compositeParameterWindow = window;
|
||||
|
||||
Keyframe keyframe = (Keyframe)itemContent;
|
||||
timeInputField.text = keyframe.time.ToString();
|
||||
valueInputField.text = keyframe.value.ToString();
|
||||
inTangentInputField.text = keyframe.inTangent.ToString();
|
||||
outTangentInputField.text = keyframe.outTangent.ToString();
|
||||
|
||||
timeInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
valueInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
inTangentInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
outTangentInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
|
||||
removeButton.onClick.AddListener(() =>
|
||||
{
|
||||
compositeParameterWindow.RemoveUnit(this);
|
||||
compositeParameterWindow.ApplyParameters();
|
||||
});
|
||||
}
|
||||
|
||||
public Keyframe GetValue()
|
||||
{
|
||||
return new Keyframe(float.Parse(timeInputField.text), float.Parse(valueInputField.text),
|
||||
float.Parse(inTangentInputField.text), float.Parse(outTangentInputField.text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c94b92b2b3fa4d6fb7af3e01fccf4ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.RhythmGame;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class DynamicUICustomCurveWrapModeUnit : DynamicUICompositeUnit
|
||||
{
|
||||
public TMP_Dropdown preWrapModeDropdown;
|
||||
public TMP_Dropdown postWrapModeDropdown;
|
||||
|
||||
public override void SetUnit(CompositeParameterWindow window, object itemContent)
|
||||
{
|
||||
compositeParameterWindow = window;
|
||||
|
||||
WarpModes warpModes = (WarpModes)itemContent;
|
||||
List<string> enumNameList = System.Enum.GetNames(typeof(WrapMode)).ToList();
|
||||
|
||||
preWrapModeDropdown.ClearOptions();
|
||||
preWrapModeDropdown.AddOptions(enumNameList);
|
||||
preWrapModeDropdown.value = (int)warpModes.preWrapMode;
|
||||
|
||||
postWrapModeDropdown.ClearOptions();
|
||||
postWrapModeDropdown.AddOptions(enumNameList);
|
||||
postWrapModeDropdown.value = (int)warpModes.postWrapMode;
|
||||
|
||||
preWrapModeDropdown.onValueChanged.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
postWrapModeDropdown.onValueChanged.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
|
||||
removeButton.onClick.AddListener(() =>
|
||||
{
|
||||
compositeParameterWindow.RemoveUnit(this);
|
||||
compositeParameterWindow.ApplyParameters();
|
||||
});
|
||||
}
|
||||
|
||||
public WarpModes GetValue()
|
||||
{
|
||||
return new WarpModes((WrapMode)preWrapModeDropdown.value, (WrapMode)postWrapModeDropdown.value);
|
||||
}
|
||||
}
|
||||
|
||||
public struct WarpModes
|
||||
{
|
||||
public WrapMode preWrapMode;
|
||||
public WrapMode postWrapMode;
|
||||
|
||||
public WarpModes(WrapMode preWrapMode, WrapMode postWrapMode)
|
||||
{
|
||||
this.preWrapMode = preWrapMode;
|
||||
this.postWrapMode = postWrapMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5c23f8ba72e5406692333306483b22e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
@@ -10,5 +11,26 @@ namespace Ichni.Editor
|
||||
public Hierarchy hierarchy;
|
||||
public Inspector inspector;
|
||||
public Timeline timeline;
|
||||
|
||||
public List<StaticWindow> staticWindows;
|
||||
|
||||
/// <summary>
|
||||
/// 快捷设置所有静态窗口的激活状态
|
||||
/// </summary>
|
||||
public void SetAllStaticWindowsActive()
|
||||
{
|
||||
bool anyWindowActive = staticWindows.Any(window => window.gameObject.activeSelf);
|
||||
staticWindows.ForEach(window =>
|
||||
{
|
||||
if (anyWindowActive)
|
||||
{
|
||||
window.DisableWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
window.EnableWindow();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,12 +206,60 @@ namespace Ichni.Editor
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, newFlexibleBool);
|
||||
};
|
||||
}
|
||||
|
||||
public void SetAsCustomCurve()
|
||||
{
|
||||
void GenerateUnit(Keyframe content)
|
||||
{
|
||||
DynamicUICustomCurveKeyframeUnit unit = Instantiate(unitPrefab, windowRect).GetComponent<DynamicUICustomCurveKeyframeUnit>();
|
||||
unitList.Add(unit);
|
||||
unit.SetUnit(this, content);
|
||||
}
|
||||
|
||||
unitPrefab = EditorManager.instance.basePrefabs.customCurveKeyframeUnit;
|
||||
AnimationCurve curve = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as AnimationCurve;
|
||||
List<Keyframe> keyframes = curve.keys.ToList();
|
||||
WarpModes warpModes = new WarpModes(curve.preWrapMode, curve.postWrapMode);
|
||||
|
||||
//生成warpModes的Unit
|
||||
DynamicUICustomCurveWrapModeUnit warpModesUnit =
|
||||
Instantiate(EditorManager.instance.basePrefabs.customCurveWrapModeUnit, windowRect).GetComponent<DynamicUICustomCurveWrapModeUnit>();
|
||||
unitList.Add(warpModesUnit);
|
||||
warpModesUnit.SetUnit(this, warpModes);
|
||||
|
||||
foreach (Keyframe keyframe in keyframes)
|
||||
{
|
||||
GenerateUnit(keyframe);
|
||||
}
|
||||
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
|
||||
addNewUnitButton.onClick.AddListener(() =>
|
||||
{
|
||||
GenerateUnit(new Keyframe(0, 0, 0, 0));
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
});
|
||||
|
||||
ApplyParameters = () =>
|
||||
{
|
||||
AnimationCurve newCurve = new AnimationCurve();
|
||||
DynamicUICustomCurveWrapModeUnit warpModesUnit = unitList[0] as DynamicUICustomCurveWrapModeUnit;
|
||||
newCurve.preWrapMode = warpModesUnit.GetValue().preWrapMode;
|
||||
newCurve.postWrapMode = warpModesUnit.GetValue().postWrapMode;
|
||||
for(int i = 1; i < unitList.Count; i++)
|
||||
{
|
||||
DynamicUICustomCurveKeyframeUnit unit = unitList[i] as DynamicUICustomCurveKeyframeUnit;
|
||||
newCurve.AddKey(unit.GetValue());
|
||||
}
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, newCurve);
|
||||
};
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
{
|
||||
ApplyParameters();
|
||||
//StartCoroutine(WindowAnim.HidePanel(gameObject, true));
|
||||
Destroy(gameObject);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class MainPage : StaticWindow
|
||||
public class MainPage : MonoBehaviour
|
||||
{
|
||||
public Canvas mainCanvas;
|
||||
public ToolBar toolBar;
|
||||
|
||||
Reference in New Issue
Block a user