Unity如何在Inspector中預覽lua指令碼的內容
阿新 • • 發佈:2018-12-19
using UnityEnging; using UnityEditor; using System.IO; [CustomeEditor(typeof(UnityEditor.DefaultAsset))] public class ShowLuaFile:Editor { public override void OnInspectorGUI() { var path = AssetDatabase.GetAssetPath(target); if(path.EndsWith(".lua")) { GUI.enabled = true; GUI.backgroundColor = new Color(60,60,60); var str = File.ReadAllText(path); if(str.Length > 1024 *20) str = str.Substring(0,1024*20)+"..."; GUILayout.TextArea(str); } } }
把這個指令碼放在Editor目錄中即可