diff --git a/Assets/TEngine/Runtime/Extension/EditorExtUtil.cs b/Assets/TEngine/Runtime/Extension/EditorExtUtil.cs index f8bfe151..4e500568 100644 --- a/Assets/TEngine/Runtime/Extension/EditorExtUtil.cs +++ b/Assets/TEngine/Runtime/Extension/EditorExtUtil.cs @@ -7,8 +7,15 @@ using Object = UnityEngine.Object; namespace TEngine { + /// + /// 编辑器运行时工具。 + /// public static class EditorExtUtil { + /// + /// 游戏物体保存为预制体。 + /// + /// 游戏物体。 public static void SavePrefabAsset(GameObject asset) { #if UNITY_EDITOR @@ -17,6 +24,11 @@ namespace TEngine #endif } + /// + /// 创建资源。 + /// + /// 游戏物体。 + /// 资源路径。 public static void CreateAsset(Object asset, string path) { #if UNITY_EDITOR @@ -25,24 +37,39 @@ namespace TEngine #endif } + /// + /// 文件路径转化成guid。 + /// + /// 文件路径 + /// guid。 public static string AssetPathToGUID(string path) { #if UNITY_EDITOR return UnityEditor.AssetDatabase.AssetPathToGUID(path); #else - return ""; + return ""; #endif } + /// + /// 获取资源来源预制体。 + /// + /// 资源实例。 + /// 来源预制体。 public static UnityEngine.Object GetPrefabParent(UnityEngine.Object obj) { #if UNITY_EDITOR return UnityEditor.PrefabUtility.GetCorrespondingObjectFromSource(obj); #else - return null; + return null; #endif } + /// + /// 获取资源路径。 + /// + /// 资源。 + /// 路径。 public static string GetAssetPath(GameObject obj) { #if UNITY_EDITOR @@ -52,6 +79,11 @@ namespace TEngine #endif } + /// + /// 获取资源路径。 + /// + /// 资源。 + /// 路径。 public static string GetAssetPath(ScriptableObject obj) { #if UNITY_EDITOR @@ -61,6 +93,12 @@ namespace TEngine #endif } + /// + /// 获取AB包中的资源依赖。 + /// + /// The name of the AssetBundle for which dependencies are required. + /// If false, returns only AssetBundles which are direct dependencies of the input; if true, includes all indirect dependencies of the input. + /// returns the list of AssetBundles that it depends on. public static string[] GetAssetBundleDependencies(string assetBundleName, bool recursive) { #if UNITY_EDITOR @@ -70,6 +108,11 @@ namespace TEngine #endif } + /// + /// guid转化成文件路径。 + /// + /// guid。 + /// 文件路径。 public static string GUIDToAssetPath(string guid) { #if UNITY_EDITOR @@ -79,33 +122,55 @@ namespace TEngine #endif } + /// + /// 编辑器下加载资源。 + /// + /// 资源地址。 + /// 资源类型。 + /// 资源实例。 public static T LoadAssetAtPath(string assetPath) where T : Object { #if UNITY_EDITOR return UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath); #else - return null; + return null; #endif } + /// + /// 获取资源包名称里的资源列表。 + /// + /// 资源包名称。 public static string[] GetAssetPathsFromAssetBundle(string assetBundleName) { #if UNITY_EDITOR return UnityEditor.AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName); #else - return null; + return null; #endif } + /// + /// 开关宏定义。 + /// + /// 宏定义。 + /// 是否开启。 public static void ToggleScriptingDefineSymbols(string def, bool isOn) { #if UNITY_EDITOR ToggleScriptingDefineSymbols(def, isOn, (int)BuildTargetGroup.Standalone); ToggleScriptingDefineSymbols(def, isOn, (int)BuildTargetGroup.Android); + ToggleScriptingDefineSymbols(def, isOn, (int)BuildTargetGroup.iOS); #endif } - static void ToggleScriptingDefineSymbols(string def, bool isOn, int type) + /// + /// 开关宏定义。 + /// + /// 宏定义。 + /// 是否开启。 + /// BuildTargetGroup打包平台类型。 + public static void ToggleScriptingDefineSymbols(string def, bool isOn, int type) { #if UNITY_EDITOR var targetGroup = (BuildTargetGroup)type; @@ -128,13 +193,21 @@ namespace TEngine } - public static void SetDirty(ScriptableObject obj) + /// + /// 设置脏标记。 + /// + /// ScriptableObject。 + public static void SetDirty(this ScriptableObject obj) { #if UNITY_EDITOR UnityEditor.EditorUtility.SetDirty(obj); #endif } + /// + /// 导入资源。 + /// + /// 资源定位地址。 public static void ImportAsset(string path) { #if UNITY_EDITOR @@ -142,7 +215,11 @@ namespace TEngine #endif } - public static void SaveTblConfig(ScriptableObject config) + /// + /// 把ScriptableObject保存为CSV表格。 + /// + /// ScriptableObject。 + public static void SaveTblConfig(this ScriptableObject config) { #if UNITY_EDITOR EditorUtility.SetDirty(config); @@ -156,6 +233,14 @@ namespace TEngine } + /// + /// 实例化游戏物体操作。 + /// + /// 来源游戏物体。 + /// 实例化的位置。 + /// 实例化的四元数。 + /// 实例化的父节点。 + /// 实例化游戏物体。 public static GameObject Instantiate( GameObject original, Vector3 position, @@ -178,6 +263,9 @@ namespace TEngine #endif } + /// + /// 停止运行游戏。 + /// public static void StopGame() { #if UNITY_EDITOR