This commit is contained in:
CortexCore
2025-03-03 18:44:00 +08:00
parent 561974a1ea
commit c29bf0d12f
84 changed files with 3986 additions and 1027 deletions

View File

@@ -22,6 +22,7 @@ namespace BITKit.GameEditor
protected ListView listView { get; private set; }
protected VisualElement container { get; private set; }
protected VisualElement _actionContainer { get; private set; }
protected TextField _newNameField { get; private set; }
private Button _createButton;
protected virtual void OnEnable()
@@ -94,11 +95,37 @@ namespace BITKit.GameEditor
{
var newNameContainer = scroll.Create<GroupBox>();
newNameContainer.style.flexDirection = FlexDirection.Row;
var newNameField = newNameContainer.Create<TextField>();
var newNameField =_newNameField = newNameContainer.Create<TextField>();
newNameField.style.flexGrow = 1;
var confirmButton = newNameContainer.Create<Button>();
confirmButton.text = "重命名";
confirmButton.clicked += () =>
{
var newName = newNameField.value;
if (string.IsNullOrEmpty(newName))
{
EditorUtility.DisplayDialog("警告", "文件名不能为空", "OK");
return;
}
var selected = listView.selectedItem as Object;
if(!selected)return;
var path = AssetDatabase.GetAssetPath(selected);
if (EditorUtility.DisplayDialog("询问", $"确定要重命名{Path.GetFileName(path)}为{newName}", "确定", "取消") is false)
{
return;
}
AssetDatabase.RenameAsset(path, newName);
RebuildList();
};
}
@@ -148,9 +175,12 @@ namespace BITKit.GameEditor
{
var selected = obj.FirstOrDefault() as Object;
var serializedObject = new SerializedObject(selected);
BITInspectorExtensions.FillDefaultInspector(container,serializedObject, true);
BITInspectorExtensions.FillDefaultInspector(container, serializedObject, true);
container.Bind(serializedObject);
if (selected)
_newNameField.SetValueWithoutNotify(selected.name);
}
protected virtual VisualElement MakeItem()
{
var container = new VisualElement();
@@ -187,6 +217,8 @@ namespace BITKit.GameEditor
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
RebuildList();
Debug.Log($"复制成功:{path}");
}
}