This commit is contained in:
陈思海 2026-03-11 15:04:33 +08:00
parent 2471317801
commit 49ecff8262

View File

@ -339,6 +339,27 @@ namespace AlicizaX.UI
? "Not Bound"
: $"Bound to: {controllerNameProp.stringValue}[{controllerIndexProp.intValue}]";
EditorGUILayout.LabelField(bindingText, EditorStyles.miniLabel);
// 在紧凑模式下也允许快速修改索引
if (!string.IsNullOrEmpty(controllerNameProp.stringValue))
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Index", GUILayout.Width(50));
int ctrlLen = GetSelectedControllerLength(recorder, controllerNameProp.stringValue);
if (ctrlLen <= 0) ctrlLen = 1;
string[] idxOptions = new string[ctrlLen];
for (int j = 0; j < ctrlLen; j++) idxOptions[j] = j.ToString();
EditorGUI.BeginChangeCheck();
int newIdx = EditorGUILayout.Popup(controllerIndexProp.intValue, idxOptions, GUILayout.Width(60));
if (EditorGUI.EndChangeCheck())
{
controllerIndexProp.intValue = newIdx;
}
EditorGUILayout.EndHorizontal();
}
}
catch (ObjectDisposedException)
{
@ -753,10 +774,9 @@ namespace AlicizaX.UI
Debug.LogException(ex);
return;
}
var recorder = serializedObject.targetObject as UXControllerStateRecorder;
if (instance != null)
{
var recorder = serializedObject.targetObject as UXControllerStateRecorder;
instance.Init(recorder);
}
@ -766,8 +786,17 @@ namespace AlicizaX.UI
stateProp.isExpanded = true;
}
controllerNameProp.stringValue = "";
controllerIndexProp.intValue = 0;
var controllerNames = GetControllerNamesForRecorder(recorder);
if (controllerNames.Count > 0)
{
controllerNameProp.stringValue = controllerNames[0];
controllerIndexProp.intValue = 0;
}
else
{
controllerNameProp.stringValue = "";
controllerIndexProp.intValue = 0;
}
serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(serializedObject.targetObject);