diff --git a/UnityProject/Assets/TEngine/Editor/Inspector/Asset.meta b/UnityProject/Assets/TEngine/Editor/Inspector/Asset.meta new file mode 100644 index 00000000..ad882a4e --- /dev/null +++ b/UnityProject/Assets/TEngine/Editor/Inspector/Asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1d6f43591dfb9c54fbbebda60c1210fa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs b/UnityProject/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs new file mode 100644 index 00000000..58d309e0 --- /dev/null +++ b/UnityProject/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs @@ -0,0 +1,52 @@ +using UnityEngine; +using UnityEditor; +using System.IO; + +[CanEditMultipleObjects, CustomEditor(typeof(DefaultAsset), false)] +public class DefaultAssetInspector : Editor +{ + private const int MaxColum = 10240; + + private GUIStyle _textStyle; + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + if (_textStyle == null) + { + _textStyle = "ScriptText"; + } + + bool enabled = GUI.enabled; + GUI.enabled = true; + string assetPath = AssetDatabase.GetAssetPath(target); + if (assetPath.EndsWith(".lua") || + assetPath.EndsWith(".properties") || + assetPath.EndsWith(".gradle") + ) + { + string luaFile = File.ReadAllText(assetPath); + string text; + if (targets.Length > 1) + { + text = Path.GetFileName(assetPath); + } + else + { + text = luaFile; + if (text.Length > MaxColum) + { + text = text.Substring(0, MaxColum) + "...\n\n<...etc...>"; + } + } + + Rect rect = GUILayoutUtility.GetRect(new GUIContent(text), _textStyle); + rect.x = 0f; + rect.y -= 3f; + rect.width = EditorGUIUtility.currentViewWidth + 1f; + GUI.Box(rect, text, _textStyle); + } + + GUI.enabled = enabled; + } +} \ No newline at end of file diff --git a/UnityProject/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs.meta b/UnityProject/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs.meta new file mode 100644 index 00000000..3fe57bdc --- /dev/null +++ b/UnityProject/Assets/TEngine/Editor/Inspector/Asset/DefaultAssetInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 83f53d2e775d0ff449616ff946f1be55 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs b/UnityProject/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs new file mode 100644 index 00000000..b2e7ea4f --- /dev/null +++ b/UnityProject/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs @@ -0,0 +1,53 @@ +using UnityEngine; +using UnityEditor; +using System.IO; + +[CanEditMultipleObjects, CustomEditor(typeof(TextAsset))] +public class TextAssetInspector : Editor +{ + private const int MaxColum = 10240; + + private GUIStyle _textStyle; + + public override void OnInspectorGUI() + { + if (_textStyle == null) + { + _textStyle = "ScriptText"; + } + + bool enabled = GUI.enabled; + GUI.enabled = true; + string assetPath = AssetDatabase.GetAssetPath(target); + if (assetPath.EndsWith(".md") + || assetPath.EndsWith(".xml") + || assetPath.EndsWith(".txt") + || assetPath.EndsWith(".html") + || assetPath.EndsWith(".csv") + ) + { + string luaFile = File.ReadAllText(assetPath); + string text; + if (base.targets.Length > 1) + { + text = Path.GetFileName(assetPath); + } + else + { + text = luaFile; + if (text.Length > MaxColum) + { + text = text.Substring(0, MaxColum) + "...\n\n<...etc...>"; + } + } + + Rect rect = GUILayoutUtility.GetRect(new GUIContent(text), _textStyle); + rect.x = 0f; + rect.y -= 3f; + rect.width = EditorGUIUtility.currentViewWidth + 1f; + GUI.Box(rect, text, _textStyle); + } + + GUI.enabled = enabled; + } +} \ No newline at end of file diff --git a/UnityProject/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs.meta b/UnityProject/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs.meta new file mode 100644 index 00000000..7d2cb6fc --- /dev/null +++ b/UnityProject/Assets/TEngine/Editor/Inspector/Asset/TextAssetInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ad0327765273616459117746a53a35e6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: