From c11baea29cd786ca2b52ba1ee18e933b69f6c799 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 18 Sep 2019 16:14:39 +0100 Subject: [PATCH 1/3] Added a custom script importer for lua files Creates text assets out of lua file contents --- .../Fungus/Scripts/Editor/LuaScriptedImporter.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs diff --git a/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs b/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs new file mode 100644 index 00000000..93789a22 --- /dev/null +++ b/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs @@ -0,0 +1,14 @@ +using UnityEngine; +using UnityEditor.Experimental.AssetImporters; +using System.IO; + +[ScriptedImporter(1, "lua")] +public class LuaScriptedImporter : ScriptedImporter +{ + public override void OnImportAsset(AssetImportContext ctx) + { + TextAsset lua = new TextAsset(File.ReadAllText(ctx.assetPath)); + ctx.AddObjectToAsset("main", lua); + ctx.SetMainObject(lua); + } +} \ No newline at end of file From 45db7b9d5de69d465bf7343ed37b05ad2d984d24 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 18 Sep 2019 16:28:20 +0100 Subject: [PATCH 2/3] Added newline at the end of file --- Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs b/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs index 93789a22..4c3f88ce 100644 --- a/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs +++ b/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs @@ -11,4 +11,4 @@ public class LuaScriptedImporter : ScriptedImporter ctx.AddObjectToAsset("main", lua); ctx.SetMainObject(lua); } -} \ No newline at end of file +} From 219c10b4648818a2179e74db5bd9cd96f00c659f Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 15 Oct 2019 11:17:11 +0100 Subject: [PATCH 3/3] Encapsulated scripted importer in Fungus.EditorUtils namespace --- .../Scripts/Editor/LuaScriptedImporter.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs b/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs index 4c3f88ce..b21a7a61 100644 --- a/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs +++ b/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs @@ -2,13 +2,16 @@ using UnityEditor.Experimental.AssetImporters; using System.IO; -[ScriptedImporter(1, "lua")] -public class LuaScriptedImporter : ScriptedImporter +namespace Fungus.EditorUtils { - public override void OnImportAsset(AssetImportContext ctx) - { - TextAsset lua = new TextAsset(File.ReadAllText(ctx.assetPath)); - ctx.AddObjectToAsset("main", lua); - ctx.SetMainObject(lua); - } -} + [ScriptedImporter(1, "lua")] + public class LuaScriptedImporter : ScriptedImporter + { + public override void OnImportAsset(AssetImportContext ctx) + { + TextAsset lua = new TextAsset(File.ReadAllText(ctx.assetPath)); + ctx.AddObjectToAsset("main", lua); + ctx.SetMainObject(lua); + } + } +} \ No newline at end of file