Gradient
This commit is contained in:
@@ -104,6 +104,10 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
customCurveWrapModeUnit: {fileID: 4259592601424320053, guid: 46049d3ff4dad4821bedf56d617ca43d,
|
||||
type: 3}
|
||||
gradientColorKeyUnit: {fileID: 4259592601424320053, guid: e56ee216cce1ea9429044153b8282b93,
|
||||
type: 3}
|
||||
gradientAlphaKeyUnit: {fileID: 4259592601424320053, guid: 5d56aba59c68c1a4992893bf869db1f3,
|
||||
type: 3}
|
||||
stringIntPairUnit: {fileID: 4259592601424320053, guid: 242457327b3d44e9db4ad431bca454c6,
|
||||
type: 3}
|
||||
graphicalFlexibleFloatWindow: {fileID: 976582014086353606, guid: 6a0b7de67a0025a44977db34773ec53c,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d56aba59c68c1a4992893bf869db1f3
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e56ee216cce1ea9429044153b8282b93
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class DynamicUIGradientAlphaKeyUnit : DynamicUICompositeUnit
|
||||
{
|
||||
public TMP_InputField colorAInputField;
|
||||
public TMP_InputField percentInputField;
|
||||
|
||||
public override void SetUnit(CompositeParameterWindow window, object itemContent)
|
||||
{
|
||||
compositeParameterWindow = window;
|
||||
|
||||
GradientAlphaKey alphaKey = (GradientAlphaKey)itemContent;
|
||||
colorAInputField.text = alphaKey.alpha.ToString();
|
||||
percentInputField.text = alphaKey.time.ToString();
|
||||
|
||||
colorAInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
percentInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
|
||||
removeButton.onClick.AddListener(() =>
|
||||
{
|
||||
compositeParameterWindow.RemoveUnit(this);
|
||||
compositeParameterWindow.ApplyParameters();
|
||||
});
|
||||
}
|
||||
|
||||
public GradientAlphaKey GetValue()
|
||||
{
|
||||
return new GradientAlphaKey(float.Parse(colorAInputField.text), float.Parse(percentInputField.text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13b978e1f66386b44a08579679b8d1ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class DynamicUIGradientColorKeyUnit : DynamicUICompositeUnit
|
||||
{
|
||||
public TMP_InputField colorRInputField;
|
||||
public TMP_InputField colorGInputField;
|
||||
public TMP_InputField colorBInputField;
|
||||
public TMP_InputField percentInputField;
|
||||
|
||||
public override void SetUnit(CompositeParameterWindow window, object itemContent)
|
||||
{
|
||||
compositeParameterWindow = window;
|
||||
|
||||
GradientColorKey colorKey = (GradientColorKey)itemContent;
|
||||
colorRInputField.text = colorKey.color.r.ToString();
|
||||
colorGInputField.text = colorKey.color.g.ToString();
|
||||
colorBInputField.text = colorKey.color.b.ToString();
|
||||
percentInputField.text = colorKey.time.ToString();
|
||||
|
||||
colorRInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
colorGInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
colorBInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
percentInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
||||
|
||||
removeButton.onClick.AddListener(() =>
|
||||
{
|
||||
compositeParameterWindow.RemoveUnit(this);
|
||||
compositeParameterWindow.ApplyParameters();
|
||||
});
|
||||
}
|
||||
|
||||
public GradientColorKey GetValue()
|
||||
{
|
||||
return new GradientColorKey(
|
||||
new Color(float.Parse(colorRInputField.text), float.Parse(colorGInputField.text), float.Parse(colorBInputField.text)),
|
||||
float.Parse(percentInputField.text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b22dbb74eb94afc47b5d75973eb2ac02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -272,6 +272,80 @@ namespace Ichni.Editor
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CompositeParameterWindow SetAsGradientColorKeys()
|
||||
{
|
||||
void GenerateUnit(GradientColorKey content)
|
||||
{
|
||||
DynamicUIGradientColorKeyUnit unit = Instantiate(unitPrefab, windowRect).GetComponent<DynamicUIGradientColorKeyUnit>();
|
||||
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();
|
||||
foreach (GradientColorKey colorKey in colorKeys)
|
||||
{
|
||||
GenerateUnit(colorKey);
|
||||
}
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
|
||||
addNewUnitButton.onClick.AddListener(() =>
|
||||
{
|
||||
GenerateUnit(new GradientColorKey(Color.white, 1));
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
});
|
||||
|
||||
ApplyParameters = () =>
|
||||
{
|
||||
List<GradientColorKey> newColorKeys = new List<GradientColorKey>();
|
||||
foreach (var unit in unitList)
|
||||
{
|
||||
newColorKeys.Add((unit as DynamicUIGradientColorKeyUnit).GetValue());
|
||||
}
|
||||
(connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as Gradient).colorKeys = newColorKeys.ToArray();
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CompositeParameterWindow SetAsGradientAlphaKeys()
|
||||
{
|
||||
void GenerateUnit(GradientAlphaKey content)
|
||||
{
|
||||
DynamicUIGradientAlphaKeyUnit unit = Instantiate(unitPrefab, windowRect).GetComponent<DynamicUIGradientAlphaKeyUnit>();
|
||||
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();
|
||||
foreach (GradientAlphaKey alphaKey in alphaKeys)
|
||||
{
|
||||
GenerateUnit(alphaKey);
|
||||
}
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
|
||||
addNewUnitButton.onClick.AddListener(() =>
|
||||
{
|
||||
GenerateUnit(new GradientAlphaKey(1, 1));
|
||||
addNewUnitButton.GetComponent<RectTransform>().SetAsLastSibling();
|
||||
});
|
||||
|
||||
ApplyParameters = () =>
|
||||
{
|
||||
List<GradientAlphaKey> newAlphaKeys = new List<GradientAlphaKey>();
|
||||
foreach (var unit in unitList)
|
||||
{
|
||||
newAlphaKeys.Add((unit as DynamicUIGradientAlphaKeyUnit).GetValue());
|
||||
}
|
||||
(connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement) as Gradient).alphaKeys = newAlphaKeys.ToArray();
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CompositeParameterWindow SetAsStringIntDictionary()
|
||||
{
|
||||
|
||||
@@ -112,7 +112,8 @@ namespace Ichni.RhythmGame
|
||||
true, this, GameCamera.CameraViewType.Perspective, 60, 10));
|
||||
var generateTrailButton = inspector.GenerateButton(this, generation, "Trail",
|
||||
() => Trail.GenerateElement("New Trail", Guid.NewGuid(), new List<string>(),
|
||||
true, this, 1, true, 1, AnimationCurve.Constant(0,1,1)));
|
||||
true, this, 1, true, 1,
|
||||
AnimationCurve.Constant(0,1,1), ColorExtensions.DefaultGradient()));
|
||||
var environmentObjectButton = inspector.GenerateButton(this, generation, "Environment Object",
|
||||
() => TemporaryObject.GenerateElement("New Environment Object", Guid.NewGuid(), new List<string>(),
|
||||
true, this));
|
||||
|
||||
@@ -101,7 +101,8 @@ namespace Ichni.RhythmGame
|
||||
var generateTrailButton = inspector.GenerateButton(this, generation, "Generate Trail", () =>
|
||||
{
|
||||
Trail.GenerateElement("New Trail", Guid.NewGuid(), new List<string>(), true,
|
||||
this, 1, true, 1, AnimationCurve.Constant(0, 1, 1));
|
||||
this, 1, true, 1,
|
||||
AnimationCurve.Constant(0, 1, 1), ColorExtensions.DefaultGradient());
|
||||
});
|
||||
var environmentObjectButton = inspector.GenerateButton(this, generation, "Environment Object",
|
||||
() => TemporaryObject.GenerateElement("New Environment Object", Guid.NewGuid(), new List<string>(),
|
||||
|
||||
@@ -17,29 +17,34 @@ namespace Ichni.RhythmGame
|
||||
public bool isAutoOrient;
|
||||
public float widthMultiplier;
|
||||
public AnimationCurve widthCurve;
|
||||
public Gradient gradient;
|
||||
|
||||
public TransformSubmodule transformSubmodule { get; set; }
|
||||
|
||||
public static Trail GenerateElement(string name, Guid id, List<string> tags, bool isFirstGenerated,
|
||||
GameElement parentElement, float visibleTimeLength, bool isAutoOrient, float widthMultiplier,
|
||||
AnimationCurve widthCurve, Material material = null)
|
||||
AnimationCurve widthCurve, Gradient gradient, Material material = null)
|
||||
{
|
||||
gradient ??= ColorExtensions.DefaultGradient();
|
||||
|
||||
Trail trail = Instantiate(EditorManager.instance.basePrefabs.trail, parentElement.transform).GetComponent<Trail>();
|
||||
trail.trailRenderer = trail.GetComponent<TrailRenderer>();
|
||||
|
||||
|
||||
trail.Initialize(name, id, tags, isFirstGenerated, parentElement);
|
||||
|
||||
trail.renderMaterial = material == null ? EditorManager.instance.basePrefabs.defaultTrailMaterial : material;
|
||||
trail.trailRenderer.material = trail.renderMaterial;
|
||||
trail.visibleTimeLength = visibleTimeLength;
|
||||
trail.isAutoOrient = isAutoOrient;
|
||||
trail.widthMultiplier = widthMultiplier;
|
||||
trail.widthCurve = widthCurve;
|
||||
trail.gradient = gradient;
|
||||
|
||||
trail.trailRenderer.material = trail.renderMaterial;
|
||||
trail.trailRenderer.time = visibleTimeLength;
|
||||
trail.trailRenderer.alignment = isAutoOrient ? LineAlignment.View : LineAlignment.TransformZ;
|
||||
trail.trailRenderer.widthMultiplier = widthMultiplier;
|
||||
trail.trailRenderer.widthCurve = widthCurve;
|
||||
trail.trailRenderer.colorGradient = gradient;
|
||||
|
||||
return trail;
|
||||
}
|
||||
@@ -83,6 +88,20 @@ namespace Ichni.RhythmGame
|
||||
widthCurveWindow.SetAsCustomCurve();
|
||||
widthCurveWindow.closeButton.onClick.AddListener(() => trailRenderer.widthCurve = widthCurve);
|
||||
});
|
||||
|
||||
var colorSettings = container.GenerateSubcontainer(3);
|
||||
var gradientColorKeysButton = inspector.GenerateButton(this, colorSettings, "Gradient Color Keys", () =>
|
||||
{
|
||||
var gradientWindow = inspector.GenerateCompositeParameterWindow(this, "Gradient Color Keys", nameof(gradient));
|
||||
gradientWindow.SetAsGradientColorKeys();
|
||||
gradientWindow.closeButton.onClick.AddListener(() => trailRenderer.colorGradient = gradient);
|
||||
});
|
||||
var gradientAlphaKeysButton = inspector.GenerateButton(this, colorSettings, "Gradient Alpha Keys", () =>
|
||||
{
|
||||
var gradientWindow = inspector.GenerateCompositeParameterWindow(this, "Gradient Alpha Keys", nameof(gradient));
|
||||
gradientWindow.SetAsGradientAlphaKeys();
|
||||
gradientWindow.closeButton.onClick.AddListener(() => trailRenderer.colorGradient = gradient);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +135,7 @@ namespace Ichni.RhythmGame
|
||||
public bool isAutoOrient;
|
||||
public float widthMultiplier;
|
||||
public AnimationCurve widthCurve;
|
||||
public Gradient gradient;
|
||||
|
||||
public Trail_BM()
|
||||
{
|
||||
@@ -138,14 +158,14 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
matchedElement = Trail.GenerateElement(elementName, elementGuid, tags,
|
||||
false, GetElement(attachedElementGuid),
|
||||
visibleTimeLength, isAutoOrient, widthMultiplier, widthCurve);
|
||||
visibleTimeLength, isAutoOrient, widthMultiplier, widthCurve, gradient);
|
||||
}
|
||||
|
||||
public override GameElement DuplicateBM(GameElement parent)
|
||||
{
|
||||
return Trail.GenerateElement(elementName, Guid.NewGuid(), tags,
|
||||
false, parent, visibleTimeLength,
|
||||
isAutoOrient, widthMultiplier, widthCurve);
|
||||
isAutoOrient, widthMultiplier, widthCurve, gradient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ public class BasePrefabsCollection : SerializedScriptableObject
|
||||
public GameObject animatedBoolUnit;
|
||||
public GameObject customCurveKeyframeUnit;
|
||||
public GameObject customCurveWrapModeUnit;
|
||||
public GameObject gradientColorKeyUnit;
|
||||
public GameObject gradientAlphaKeyUnit;
|
||||
public GameObject stringIntPairUnit;
|
||||
[Title("图形化动画编辑器")]
|
||||
public GameObject graphicalFlexibleFloatWindow;
|
||||
|
||||
23
Assets/Scripts/Settings/ColorExtensions.cs
Normal file
23
Assets/Scripts/Settings/ColorExtensions.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class ColorExtensions
|
||||
{
|
||||
public static Gradient DefaultGradient()
|
||||
{
|
||||
Gradient gradient = new Gradient();
|
||||
GradientColorKey[] colorKeys = new GradientColorKey[2];
|
||||
colorKeys[0].color = Color.white;
|
||||
colorKeys[0].time = 0;
|
||||
colorKeys[1].color = Color.white;
|
||||
colorKeys[1].time = 1;
|
||||
GradientAlphaKey[] alphaKeys = new GradientAlphaKey[2];
|
||||
alphaKeys[0].alpha = 1;
|
||||
alphaKeys[0].time = 0;
|
||||
alphaKeys[1].alpha = 1;
|
||||
alphaKeys[1].time = 1;
|
||||
gradient.SetKeys(colorKeys, alphaKeys);
|
||||
return gradient;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Settings/ColorExtensions.cs.meta
Normal file
11
Assets/Scripts/Settings/ColorExtensions.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b994ac82f6ab6cd42bf64438e79d1965
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -505,6 +505,12 @@
|
||||
"startTime" : 0,
|
||||
"endTime" : 4,
|
||||
"animationCurveType" : 0
|
||||
},{
|
||||
"startValue" : 0,
|
||||
"endValue" : 1,
|
||||
"startTime" : 0,
|
||||
"endTime" : 4,
|
||||
"animationCurveType" : 0
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -549,6 +555,7 @@
|
||||
"preWrapMode" : 8,
|
||||
"postWrapMode" : 8
|
||||
},
|
||||
"gradient" : null,
|
||||
"elementName" : "New Trail",
|
||||
"tags" : [
|
||||
|
||||
|
||||
Reference in New Issue
Block a user