From cf589b2475846f3bcb1bbb7b2c2af61dbf3f476f Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Mon, 4 Apr 2016 15:24:56 +0100 Subject: [PATCH] Moved stringtable to unity table --- Assets/Fungus/Lua/Scripts/LuaUtils.cs | 6 +++++- Assets/Tests/Lua/FungusTests.unity | 2 +- Assets/Tests/Lua/LuaEnvironmentTests.unity | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Assets/Fungus/Lua/Scripts/LuaUtils.cs b/Assets/Fungus/Lua/Scripts/LuaUtils.cs index 9daf444e..2f957d3d 100644 --- a/Assets/Fungus/Lua/Scripts/LuaUtils.cs +++ b/Assets/Fungus/Lua/Scripts/LuaUtils.cs @@ -175,7 +175,11 @@ namespace Fungus if (stringTableRes.Type == DataType.Table) { stringTableCached = stringTableRes.Table; - interpreter.Globals["stringtable"] = stringTableCached; + Table unityTable = interpreter.Globals.Get("unity").Table; + if (unityTable != null) + { + unityTable["stringtable"] = stringTableCached; + } } } catch (ScriptRuntimeException ex) diff --git a/Assets/Tests/Lua/FungusTests.unity b/Assets/Tests/Lua/FungusTests.unity index 7b5d5252..8c085390 100644 --- a/Assets/Tests/Lua/FungusTests.unity +++ b/Assets/Tests/Lua/FungusTests.unity @@ -956,7 +956,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &110417826 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Tests/Lua/LuaEnvironmentTests.unity b/Assets/Tests/Lua/LuaEnvironmentTests.unity index af63dbab..818ad403 100644 --- a/Assets/Tests/Lua/LuaEnvironmentTests.unity +++ b/Assets/Tests/Lua/LuaEnvironmentTests.unity @@ -1369,7 +1369,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!114 &1532103953 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1622,14 +1622,14 @@ MonoBehaviour: luaFile: {fileID: 0} luaScript: '-- Test string table localisation system - fungus.assert(stringtable != nil) + fungus.assert(unity.stringtable != nil) -- Check string table loaded ok - fungus.assert(stringtable.hello.en == "Hi there") + fungus.assert(unity.stringtable.hello.en == "Hi there") - fungus.assert(stringtable.hello.fr == "Bonjour") + fungus.assert(unity.stringtable.hello.fr == "Bonjour") -- Check getstring()