NLDClient-yudde/ProjectNLD/Assets/Editor/LevelEditor/LevelEditorHelper.cs

22 lines
877 B
C#
Raw Normal View History

2023-11-19 22:57:17 +08:00
using System.Collections;
using System.Collections.Generic;
2023-12-22 19:00:27 +08:00
using System.IO;
2023-11-19 22:57:17 +08:00
using UnityEditor;
using UnityEngine;
public static class LevelEditorHelper
{
2023-12-20 17:19:51 +08:00
private const string LEVEL_TEMPLATE_PATH = "Assets/Scenes/Maps/Template/MapDefault/MapDefault.unity";
2023-12-22 19:00:27 +08:00
2023-12-20 17:19:51 +08:00
[MenuItem("Assets/创建地图场景")]
2023-11-19 22:57:17 +08:00
private static void CreateLevel()
{
2023-12-22 19:00:27 +08:00
var currDir = EditorUtil.GetCurrentAssetDirectory().Replace("\\", "/");
var dirName = Path.GetFileName(currDir);
var count = AssetDatabase.FindAssets("t:SceneAsset", new[] { currDir }).Length + 1;
var savePath = EditorUtil.GetAssetUniquePath($"{currDir}/{dirName}_{count}.unity", out var assetName);
AssetDatabase.CopyAsset(LEVEL_TEMPLATE_PATH, savePath);
var newScene = AssetDatabase.LoadAssetAtPath<SceneAsset>(savePath);
2023-11-20 12:25:41 +08:00
EditorGUIUtility.PingObject(newScene);
2023-11-19 22:57:17 +08:00
}
2023-12-22 19:00:27 +08:00
}