update handling of Lua assets
This commit is contained in:
@@ -5,11 +5,11 @@ using UnityEngine;
|
||||
[CustomEditor(typeof(LuaFile))]
|
||||
public class LuaScriptAssetEditor : Editor
|
||||
{
|
||||
private TextAsset asset;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
LuaFile luaScriptAsset = (LuaFile)target;
|
||||
|
||||
// Allow user to drag-and-drop the Lua file
|
||||
luaScriptAsset.luaScript = (TextAsset)EditorGUILayout.ObjectField("Lua Script", luaScriptAsset.luaScript, typeof(TextAsset), false);
|
||||
EditorGUILayout.TextArea(luaScriptAsset.LuaScript);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.AssetImporters;
|
||||
using Splashedit.RuntimeCode;
|
||||
|
||||
namespace SplashEdit.EditorCode
|
||||
{
|
||||
@@ -9,9 +11,15 @@ namespace SplashEdit.EditorCode
|
||||
{
|
||||
public override void OnImportAsset(AssetImportContext ctx)
|
||||
{
|
||||
var asset = new TextAsset(File.ReadAllText(ctx.assetPath));
|
||||
ctx.AddObjectToAsset("Text", asset);
|
||||
ctx.SetMainObject(asset);
|
||||
var asset = ScriptableObject.CreateInstance<LuaFile>();
|
||||
var luaCode = File.ReadAllText(ctx.assetPath);
|
||||
asset.Init(luaCode);
|
||||
asset.name = Path.GetFileName(ctx.assetPath);
|
||||
var text = new TextAsset(asset.LuaScript);
|
||||
|
||||
ctx.AddObjectToAsset("Text", text);
|
||||
ctx.AddObjectToAsset("Script", asset);
|
||||
ctx.SetMainObject(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user