曲线视觉编辑器,初步
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Ichni.Editor
|
||||
this.connectedBaseElement = baseElement;
|
||||
this.parameterName = parameterName;
|
||||
unitList = new List<DynamicUICompositeUnit>();
|
||||
|
||||
|
||||
InitializeWindow(titleText, ApplyParameters);
|
||||
|
||||
StartCoroutine(WindowAnim.ShowPanelOnScale(gameObject));
|
||||
@@ -34,7 +34,7 @@ namespace Ichni.Editor
|
||||
unitList.Remove(unit);
|
||||
Destroy(unit.gameObject);
|
||||
}
|
||||
|
||||
|
||||
public CompositeParameterWindow AddListenerFunction(UnityAction action)
|
||||
{
|
||||
onQuit = action;
|
||||
@@ -77,7 +77,7 @@ namespace Ichni.Editor
|
||||
List<string> stringList = unitList.Select(unit => (unit as DynamicUIInputFieldUnit).GetValue<string>()).ToList();
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, stringList);
|
||||
};
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Ichni.Editor
|
||||
List<float> floatList = unitList.Select(unit => (unit as DynamicUIInputFieldUnit).GetValue<float>()).ToList();
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, floatList);
|
||||
};
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Ichni.Editor
|
||||
}
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, newFlexibleFloat);
|
||||
};
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace Ichni.Editor
|
||||
}
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, newFlexibleInt);
|
||||
};
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -219,12 +219,19 @@ namespace Ichni.Editor
|
||||
}
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, newFlexibleBool);
|
||||
};
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public KeyframeVisualizer keyframeVisualizer;
|
||||
public CompositeParameterWindow SetAsCustomCurve()
|
||||
{
|
||||
|
||||
//生成一个预览器先
|
||||
keyframeVisualizer.gameObject.SetActive(true);
|
||||
//
|
||||
void GenerateUnit(Keyframe content)
|
||||
{
|
||||
DynamicUICustomCurveKeyframeUnit unit = Instantiate(unitPrefab, windowRect).GetComponent<DynamicUICustomCurveKeyframeUnit>();
|
||||
@@ -242,6 +249,11 @@ namespace Ichni.Editor
|
||||
Instantiate(EditorManager.instance.basePrefabs.customCurveWrapModeUnit, windowRect).GetComponent<DynamicUICustomCurveWrapModeUnit>();
|
||||
unitList.Add(warpModesUnit);
|
||||
warpModesUnit.SetUnit(this, warpModes);
|
||||
//
|
||||
keyframeVisualizer.curve = curve;
|
||||
keyframeVisualizer.DrawCurveToRawImage();
|
||||
keyframeVisualizer.CreateKeyframeImages();
|
||||
//
|
||||
|
||||
foreach (Keyframe keyframe in keyframes)
|
||||
{
|
||||
@@ -268,8 +280,8 @@ namespace Ichni.Editor
|
||||
newCurve.AddKey(unit.GetValue());
|
||||
}
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, newCurve);
|
||||
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -281,7 +293,7 @@ namespace Ichni.Editor
|
||||
unitList.Add(unit);
|
||||
unit.SetUnit(this, content);
|
||||
}
|
||||
|
||||
|
||||
unitPrefab = EditorManager.instance.basePrefabs.gradientColorKeyUnit;
|
||||
Gradient gradient = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as Gradient;
|
||||
List<GradientColorKey> colorKeys = gradient.colorKeys.ToList();
|
||||
@@ -296,7 +308,7 @@ namespace Ichni.Editor
|
||||
GenerateUnit(new GradientColorKey(Color.white, 1));
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
});
|
||||
|
||||
|
||||
ApplyParameters = () =>
|
||||
{
|
||||
List<GradientColorKey> newColorKeys = new List<GradientColorKey>();
|
||||
@@ -306,10 +318,10 @@ namespace Ichni.Editor
|
||||
}
|
||||
(connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as Gradient).colorKeys = newColorKeys.ToArray();
|
||||
};
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CompositeParameterWindow SetAsGradientAlphaKeys()
|
||||
{
|
||||
void GenerateUnit(GradientAlphaKey content)
|
||||
@@ -318,7 +330,7 @@ namespace Ichni.Editor
|
||||
unitList.Add(unit);
|
||||
unit.SetUnit(this, content);
|
||||
}
|
||||
|
||||
|
||||
unitPrefab = EditorManager.instance.basePrefabs.gradientAlphaKeyUnit;
|
||||
Gradient gradient = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as Gradient;
|
||||
List<GradientAlphaKey> alphaKeys = gradient.alphaKeys.ToList();
|
||||
@@ -333,7 +345,7 @@ namespace Ichni.Editor
|
||||
GenerateUnit(new GradientAlphaKey(1, 1));
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
});
|
||||
|
||||
|
||||
ApplyParameters = () =>
|
||||
{
|
||||
List<GradientAlphaKey> newAlphaKeys = new List<GradientAlphaKey>();
|
||||
@@ -343,10 +355,10 @@ namespace Ichni.Editor
|
||||
}
|
||||
(connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as Gradient).alphaKeys = newAlphaKeys.ToArray();
|
||||
};
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CompositeParameterWindow SetAsStringIntDictionary()
|
||||
{
|
||||
//生成Unit
|
||||
@@ -358,13 +370,13 @@ namespace Ichni.Editor
|
||||
}
|
||||
|
||||
unitPrefab = EditorManager.instance.basePrefabs.stringIntPairUnit;
|
||||
|
||||
|
||||
Dictionary<string, int> dictionary = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as Dictionary<string, int>;
|
||||
foreach (var pair in dictionary)
|
||||
{
|
||||
GenerateUnit(pair);
|
||||
}
|
||||
|
||||
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
|
||||
//为添加新的Unit的按钮设置点击事件
|
||||
@@ -385,7 +397,7 @@ namespace Ichni.Editor
|
||||
}
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, dictionaryList);
|
||||
};
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user