Added lua exporting

This commit is contained in:
2025-04-09 22:20:52 +02:00
parent 765575d7ae
commit b3da188438
10 changed files with 161 additions and 34 deletions

View File

@@ -0,0 +1,15 @@
using Splashedit.RuntimeCode;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(LuaFile))]
public class LuaScriptAssetEditor : Editor
{
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);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 32c0501d523345500be12e6e4214ec9d

17
Editor/LuaImporter.cs Normal file
View File

@@ -0,0 +1,17 @@
using UnityEngine;
using System.IO;
using UnityEditor.AssetImporters;
namespace SplashEdit.EditorCode
{
[ScriptedImporter(1, "lua")]
class LuaImporter : ScriptedImporter
{
public override void OnImportAsset(AssetImportContext ctx)
{
var asset = new TextAsset(File.ReadAllText(ctx.assetPath));
ctx.AddObjectToAsset("Text", asset);
ctx.SetMainObject(asset);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d364a1392e3bccd77aca824ac471f89c