一些特效
This commit is contained in:
@@ -12,6 +12,8 @@ namespace Ichni.Editor
|
||||
public class DynamicUIEmissionColorPicker : DynamicUIElement
|
||||
{
|
||||
private string emissionEnabledName, colorParameterName, emissionIntensityName;
|
||||
private bool canDisableEmission;
|
||||
|
||||
public Toggle toggleEnableEmission;
|
||||
public TMP_InputField inputFieldEmissionR;
|
||||
public TMP_InputField inputFieldEmissionG;
|
||||
@@ -27,15 +29,27 @@ namespace Ichni.Editor
|
||||
string emissionEnabledName, string colorParameterName, string emissionIntensityName)
|
||||
{
|
||||
base.Initialize(baseElement, title, colorParameterName);
|
||||
|
||||
canDisableEmission = emissionEnabledName != "NULL"; //如果对应的EmissionColor强制开启,那么其enabledName为"NULL",不需要显示Toggle
|
||||
|
||||
this.emissionEnabledName = emissionEnabledName;
|
||||
this.colorParameterName = colorParameterName;
|
||||
this.emissionIntensityName = emissionIntensityName;
|
||||
|
||||
bool enableEmission = (bool)connectedBaseElement.GetType().GetField(emissionEnabledName).GetValue(connectedBaseElement);
|
||||
if(canDisableEmission)
|
||||
{
|
||||
bool enableEmission = (bool)connectedBaseElement.GetType().GetField(emissionEnabledName).GetValue(connectedBaseElement);
|
||||
toggleEnableEmission.isOn = enableEmission;
|
||||
toggleEnableEmission.onValueChanged.AddListener(_ => ApplyParameters());
|
||||
}
|
||||
else
|
||||
{
|
||||
toggleEnableEmission.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
Color emissionColor = (Color)connectedBaseElement.GetType().GetField(colorParameterName).GetValue(connectedBaseElement);
|
||||
float emissionIntensity = (float)connectedBaseElement.GetType().GetField(emissionIntensityName).GetValue(connectedBaseElement);
|
||||
|
||||
toggleEnableEmission.isOn = enableEmission;
|
||||
inputFieldEmissionR.text = emissionColor.r.ToString();
|
||||
inputFieldEmissionG.text = emissionColor.g.ToString();
|
||||
inputFieldEmissionB.text = emissionColor.b.ToString();
|
||||
@@ -48,8 +62,6 @@ namespace Ichni.Editor
|
||||
sliderG.onValueChanged.AddListener(SliderChange);
|
||||
sliderB.onValueChanged.AddListener(SliderChange);
|
||||
|
||||
|
||||
toggleEnableEmission.onValueChanged.AddListener(_ => ApplyParameters());
|
||||
inputFieldEmissionR.onEndEdit.AddListener(_ => ApplyParameters());
|
||||
inputFieldEmissionG.onEndEdit.AddListener(_ => ApplyParameters());
|
||||
inputFieldEmissionB.onEndEdit.AddListener(_ => ApplyParameters());
|
||||
@@ -64,8 +76,12 @@ namespace Ichni.Editor
|
||||
Color emissionColor = new Color(float.Parse(inputFieldEmissionR.text), float.Parse(inputFieldEmissionG.text),
|
||||
float.Parse(inputFieldEmissionB.text));
|
||||
float emissionIntensity = float.Parse(inputFieldEmissionI.text);
|
||||
|
||||
connectedBaseElement.GetType().GetField(emissionEnabledName).SetValue(connectedBaseElement, enableEmission);
|
||||
|
||||
if (canDisableEmission)
|
||||
{
|
||||
connectedBaseElement.GetType().GetField(emissionEnabledName).SetValue(connectedBaseElement, enableEmission);
|
||||
}
|
||||
|
||||
connectedBaseElement.GetType().GetField(colorParameterName).SetValue(connectedBaseElement, emissionColor);
|
||||
connectedBaseElement.GetType().GetField(emissionIntensityName).SetValue(connectedBaseElement, emissionIntensity);
|
||||
colorPreview.color = emissionColor;
|
||||
@@ -82,8 +98,11 @@ namespace Ichni.Editor
|
||||
|
||||
public override DynamicUIElement AddListenerFunction(UnityAction action)
|
||||
{
|
||||
toggleEnableEmission.onValueChanged.AddListener(_ => action());
|
||||
|
||||
if (canDisableEmission)
|
||||
{
|
||||
toggleEnableEmission.onValueChanged.AddListener(_ => action());
|
||||
}
|
||||
|
||||
inputFieldEmissionR.onEndEdit.AddListener(_ => action());
|
||||
inputFieldEmissionG.onEndEdit.AddListener(_ => action());
|
||||
inputFieldEmissionB.onEndEdit.AddListener(_ => action());
|
||||
|
||||
Reference in New Issue
Block a user