Storyline+Dialog初步
This commit is contained in:
58
Packages/io.continis.subassets/Editor/SubAssetContextMenu.cs
Normal file
58
Packages/io.continis.subassets/Editor/SubAssetContextMenu.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SubAssetsToolbox.Editor
|
||||
{
|
||||
public static class SubAssetContextMenu
|
||||
{
|
||||
#if UNITY_6000
|
||||
private const int MenuPriority = 20;
|
||||
#else
|
||||
private const int MenuPriority = 19;
|
||||
#endif
|
||||
|
||||
[MenuItem("Assets/Delete Sub-Asset(s)", false, MenuPriority)]
|
||||
private static void DeleteSubAsset()
|
||||
{
|
||||
bool isOne = Selection.objects.Length == 1;
|
||||
|
||||
bool decision = EditorUtility.DisplayDialog(
|
||||
isOne ? "Delete Sub-Asset" : "Delete Sub-Assets",
|
||||
isOne
|
||||
? string.Format(Constants.ConfirmDeleteSubAsset, Selection.objects[0].name)
|
||||
: string.Format(Constants.ConfirmDeleteSubAssets, Selection.objects[0].name, Selection.objects[1].name),
|
||||
isOne ? "Delete" : "Delete all",
|
||||
"Cancel");
|
||||
|
||||
if (!decision) return;
|
||||
|
||||
foreach (Object obj in Selection.objects)
|
||||
{
|
||||
string parentObjectPath = AssetDatabase.GetAssetPath(obj);
|
||||
SubAssetsToolbox.RemoveSubAsset(parentObjectPath, obj);
|
||||
}
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Delete Sub-Asset(s)", true)]
|
||||
private static bool ValidateDeleteSubAsset()
|
||||
{
|
||||
return Selection.objects.Length > 0 && Selection.objects.All(AssetDatabase.IsSubAsset);
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Rename Sub-Asset", false, MenuPriority)]
|
||||
private static void RenameSubAsset()
|
||||
{
|
||||
RenameSubAssetWindow.Open(Selection.activeObject);
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Rename Sub-Asset", true)]
|
||||
private static bool ValidateRenameSubAsset()
|
||||
{
|
||||
return Selection.objects.Length == 1 && AssetDatabase.IsSubAsset(Selection.activeObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user