This commit is contained in:
SoulliesOfficial
2026-06-09 07:00:19 -04:00
parent 5fc1392747
commit e97646ae48
6 changed files with 111 additions and 60 deletions

View File

@@ -29,6 +29,16 @@ namespace Ichni.Editor
public override void Initialize(IBaseElement baseElement, string title, string parameterName)
{
// [对象池安全] 重置可交互状态
if (sliderR != null) sliderR.interactable = true;
if (sliderG != null) sliderG.interactable = true;
if (sliderB != null) sliderB.interactable = true;
if (sliderA != null) sliderA.interactable = true;
if (inputFieldBaseR != null) inputFieldBaseR.interactable = true;
if (inputFieldBaseG != null) inputFieldBaseG.interactable = true;
if (inputFieldBaseB != null) inputFieldBaseB.interactable = true;
if (inputFieldBaseA != null) inputFieldBaseA.interactable = true;
base.Initialize(baseElement, title, parameterName);
Color baseColor = (Color)connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement);

View File

@@ -31,10 +31,19 @@ namespace Ichni.Editor
public virtual void Initialize(IBaseElement baseElement, string title, string parameterName)
{
if (canvasGroup == null) canvasGroup = gameObject.AddComponent<CanvasGroup>();
// [对象池安全] 重置 CanvasGroup 状态,防止上次 EnabledIf 设置的禁用状态泄漏到新的元素实例
canvasGroup.interactable = true;
canvasGroup.alpha = 1f;
canvasGroup.blocksRaycasts = true;
this.connectedBaseElement = baseElement;
this.parameterName = parameterName;
if (title != string.Empty)
{
// [对象池安全] 确保标题 GameObject 处于激活状态,
// 防止上次以空标题使用时 SetActive(false) 的状态泄漏
this.title.gameObject.SetActive(true);
this.title.text = title;
}
else

View File

@@ -29,6 +29,29 @@ namespace Ichni.Editor
public void Initialize(IBaseElement baseElement, string title,
string emissionEnabledName, string colorParameterName, string emissionIntensityName)
{
// [对象池安全] 重置可交互状态
if (toggleEnableEmission != null) toggleEnableEmission.interactable = true;
if (sliderR != null) sliderR.interactable = true;
if (sliderG != null) sliderG.interactable = true;
if (sliderB != null) sliderB.interactable = true;
if (inputFieldEmissionR != null) inputFieldEmissionR.interactable = true;
if (inputFieldEmissionG != null) inputFieldEmissionG.interactable = true;
if (inputFieldEmissionB != null) inputFieldEmissionB.interactable = true;
if (inputFieldEmissionI != null) inputFieldEmissionI.interactable = true;
// [对象池安全] 清除上次使用残留的监听器
toggleEnableEmission.onValueChanged.RemoveAllListeners();
sliderR.onValueChanged.RemoveListener(SliderChange);
sliderG.onValueChanged.RemoveListener(SliderChange);
sliderB.onValueChanged.RemoveListener(SliderChange);
inputFieldEmissionR.onEndEdit.RemoveAllListeners();
inputFieldEmissionG.onEndEdit.RemoveAllListeners();
inputFieldEmissionB.onEndEdit.RemoveAllListeners();
inputFieldEmissionI.onEndEdit.RemoveAllListeners();
// [对象池安全] 确保 Toggle GameObject 处于激活状态(可能上次被隐藏过)
toggleEnableEmission.gameObject.SetActive(true);
base.Initialize(baseElement, title, colorParameterName);
canDisableEmission = emissionEnabledName != "NULL"; //如果对应的EmissionColor强制开启那么其enabledName为"NULL"不需要显示Toggle

View File

@@ -28,6 +28,12 @@ namespace Ichni.Editor
public void Initialize(IBaseElement baseElement, string title, string parameterName,
float min, float max, bool wholeNumbers = false)
{
// [对象池安全] 重置可交互状态
if (slider != null) slider.interactable = true;
if (valueInputField != null) valueInputField.interactable = true;
if (minInputField != null) minInputField.interactable = true;
if (maxInputField != null) maxInputField.interactable = true;
slider.minValue = min;
slider.maxValue = max;
slider.wholeNumbers = wholeNumbers;

View File

@@ -15,6 +15,9 @@ namespace Ichni.Editor
public override void Initialize(IBaseElement baseElement, string title, string parameterName)
{
// [对象池安全] 重置可交互状态
if (toggle != null) toggle.interactable = true;
// [对象池安全] 精准解绑业务代理,不动预制体原生的展示事件!
toggle.onValueChanged.RemoveListener(OnToggleValueChanged);
customAction = null;