111
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ARMazTools.editor",
|
"name": "ARMazTools.editor",
|
||||||
"rootNamespace": "",
|
"rootNamespace": "",
|
||||||
"references": [],
|
"references": [
|
||||||
|
"GUID:516ee79c2bc5cf24d849362a3f9036d5"
|
||||||
|
],
|
||||||
"includePlatforms": [
|
"includePlatforms": [
|
||||||
"Editor"
|
"Editor"
|
||||||
],
|
],
|
||||||
|
|||||||
57
Assets/00.ARMazTools/Editor/CreatDomainDirectory.cs
Normal file
57
Assets/00.ARMazTools/Editor/CreatDomainDirectory.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public static class CreatDomainDirectory
|
||||||
|
{
|
||||||
|
static CreatDomainDirectory()
|
||||||
|
{
|
||||||
|
// 注意 因为这个构造函数会被重复调用,
|
||||||
|
//所以为了防止quitting和update两个回调被重复添加,需要先移除后添加
|
||||||
|
EditorApplication.quitting -= OnEditorQuit;
|
||||||
|
EditorApplication.quitting += OnEditorQuit;
|
||||||
|
|
||||||
|
Debug.Log(" 自动运行 ");
|
||||||
|
|
||||||
|
if (!EditorPrefs.HasKey("StartUp"))
|
||||||
|
{
|
||||||
|
// 通过标记记录是否已经执行过该方法
|
||||||
|
OnEditorStartUp();
|
||||||
|
EditorPrefs.SetInt("StartUp", 1);
|
||||||
|
|
||||||
|
if (EditorPrefs.GetInt("CreatDomainDirectory") == 0)
|
||||||
|
{
|
||||||
|
EditorPrefs.SetInt("CreatDomainDirectory", 1);
|
||||||
|
bool isOk = EditorUtility.DisplayDialog("提示", "发现目录存在缺失,是否检索并创建缺失目录", "是", "否");
|
||||||
|
if (isOk)
|
||||||
|
{
|
||||||
|
var DomainAll = EvoArtFolderCreator.RefreshModuleList();
|
||||||
|
foreach (var domain in DomainAll)
|
||||||
|
{
|
||||||
|
EvoArtFolderCreator.CreateFolders(domain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// UnityEditor 关闭时取消标记
|
||||||
|
/// </summary>
|
||||||
|
private static void OnEditorQuit()
|
||||||
|
{
|
||||||
|
EditorPrefs.DeleteKey("StartUp");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 只会在UnityEditor启动时执行一次
|
||||||
|
/// </summary>
|
||||||
|
static void OnEditorStartUp()
|
||||||
|
{
|
||||||
|
Debug.Log(" UnityEditor 启动 ");
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/00.ARMazTools/Editor/CreatDomainDirectory.cs.meta
Normal file
11
Assets/00.ARMazTools/Editor/CreatDomainDirectory.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ea8ae43a0c279e64eb666829f54020fc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
137
Assets/00.ARMazTools/Editor/EvoArtFolderCreator.cs
Normal file
137
Assets/00.ARMazTools/Editor/EvoArtFolderCreator.cs
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
using System.IO;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Linq;
|
||||||
|
using Stary.Evo.Editor;
|
||||||
|
|
||||||
|
public class EvoArtFolderCreator : EditorWindow
|
||||||
|
{
|
||||||
|
static string[] moduleNames; // 下拉列表
|
||||||
|
static int selectedIndex; // 当前选中的下标
|
||||||
|
|
||||||
|
[MenuItem("Evo/创建Art文件夹")]
|
||||||
|
static void OpenCreator()
|
||||||
|
{
|
||||||
|
var w = GetWindowWithRect<EvoArtFolderCreator>(new Rect(0, 0, 350, 110), true, "创建点位");
|
||||||
|
w.minSize = w.maxSize = new Vector2(350, 110);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
RefreshModuleList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnGUI()
|
||||||
|
{
|
||||||
|
GUILayout.Space(10);
|
||||||
|
|
||||||
|
bool hasModule = moduleNames != null && moduleNames.Length > 0;
|
||||||
|
if (!hasModule)
|
||||||
|
EditorGUILayout.HelpBox("未找到 Assets/Modules 目录或目录下无子文件夹!", MessageType.Warning);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EditorGUILayout.LabelField("选择模块(点位)", EditorStyles.boldLabel);
|
||||||
|
selectedIndex = EditorGUILayout.Popup(selectedIndex, moduleNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.FlexibleSpace();
|
||||||
|
|
||||||
|
// ****** 关键:BeginHorizontal 始终闭合 ******
|
||||||
|
using (new EditorGUILayout.HorizontalScope())
|
||||||
|
{
|
||||||
|
GUILayout.FlexibleSpace();
|
||||||
|
|
||||||
|
GUI.enabled = hasModule; // 禁用按钮而不是提前 return
|
||||||
|
if (GUILayout.Button("创建点位", GUILayout.Width(100), GUILayout.Height(25)))
|
||||||
|
{
|
||||||
|
CreateFolders(moduleNames[selectedIndex]);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
if (GUILayout.Button("标记资源", GUILayout.Width(100), GUILayout.Height(25)))
|
||||||
|
{
|
||||||
|
MarkAdressable.AddDomainMark(moduleNames[selectedIndex]);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
GUI.enabled = true;
|
||||||
|
|
||||||
|
if (GUILayout.Button("取消", GUILayout.Width(100), GUILayout.Height(25)))
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重新扫描 Modules 子文件夹
|
||||||
|
/// </summary>
|
||||||
|
public static string[] RefreshModuleList()
|
||||||
|
{
|
||||||
|
string modulesRoot = Path.Combine(Application.dataPath, "Modules");
|
||||||
|
if (!Directory.Exists(modulesRoot))
|
||||||
|
{
|
||||||
|
moduleNames = new string[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 只取一级目录名
|
||||||
|
moduleNames = Directory.GetDirectories(modulesRoot)
|
||||||
|
.Select(p => Path.GetFileName(p))
|
||||||
|
.ToArray();
|
||||||
|
selectedIndex = 0;
|
||||||
|
return moduleNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 仅替换原来的 CreateFolders 方法即可
|
||||||
|
public static void CreateFolders(string name)
|
||||||
|
{
|
||||||
|
string root = Path.Combine(Application.dataPath, "Art", name);
|
||||||
|
string sceneDir = Path.Combine(root, "Scenes", "Test"); // Scenes/Test
|
||||||
|
string[] dirs =
|
||||||
|
{
|
||||||
|
"Animation", "Effects", "Fbx", "Font", "Materials",
|
||||||
|
"Prefabs", "Scenes", "Shader", "Textures"
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
/* 1. 创建所有基础目录 */
|
||||||
|
foreach (var dir in dirs)
|
||||||
|
{
|
||||||
|
string full = Path.Combine(root, dir);
|
||||||
|
if (!Directory.Exists(full)) Directory.CreateDirectory(full);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 2. 再建 Scenes/Test */
|
||||||
|
if (!Directory.Exists(sceneDir))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(sceneDir);
|
||||||
|
/* 3. 创建新场景 */
|
||||||
|
var newScene = UnityEditor.SceneManagement.EditorSceneManager.NewScene(
|
||||||
|
UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects,
|
||||||
|
UnityEditor.SceneManagement.NewSceneMode.Single);
|
||||||
|
|
||||||
|
/* 4. 删除默认相机(和灯光)*/
|
||||||
|
foreach (var go in newScene.GetRootGameObjects())
|
||||||
|
{
|
||||||
|
if (go.name == "Main Camera" || go.name == "Directional Light")
|
||||||
|
GameObject.DestroyImmediate(go);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 5. 载入并实例化 RKCameraRig.prefab */
|
||||||
|
string prefabPath = "Prefabs/BaseSetting/RKCameraRig";
|
||||||
|
|
||||||
|
var prefab = Resources.Load<GameObject>(prefabPath);
|
||||||
|
var spawned = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||||
|
spawned.name = "RKCameraRig";
|
||||||
|
|
||||||
|
/* 6. 保存场景 */
|
||||||
|
string scenePath = Path.Combine("Assets/Art", name, "Scenes", "Test", "TestScene.unity");
|
||||||
|
UnityEditor.SceneManagement.EditorSceneManager.SaveScene(newScene, scenePath);
|
||||||
|
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
EditorUtility.DisplayDialog("成功", $"已生成完整目录及 TestScene(含 RKCameraRig)!", "确定");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
EditorUtility.DisplayDialog("错误", "创建失败:\n" + e.Message, "确定");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/00.ARMazTools/Editor/EvoArtFolderCreator.cs.meta
Normal file
11
Assets/00.ARMazTools/Editor/EvoArtFolderCreator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fa01e64b03de6d74db2dc57df3dcc524
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "com.staryevo.armaztools",
|
"name": "com.staryevo.armaztools",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"displayName": "00.StaryEvo.ARMazTools",
|
"displayName": "00.StaryEvo.ARMazTools",
|
||||||
"description": "This is an ARMazTools package(后台服务器版本,端口9527)",
|
"description": "This is an ARMazTools package(后台服务器版本,端口9527)",
|
||||||
"unity": "2021.3",
|
"unity": "2021.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user