Browse Source

Split LuaEnvironment into LuaEnvironment & LuaUtils components

master
chrisgregan 9 years ago
parent
commit
77504aa59d
  1. 26
      Assets/Fungus/Lua/Resources/Lua/fungus.txt
  2. 18
      Assets/Fungus/Lua/Resources/Prefabs/LuaEnvironment.prefab
  3. 2
      Assets/Fungus/Lua/Resources/Types/ExtensionTypes.txt
  4. 8
      Assets/Fungus/Lua/Resources/Types/ExtensionTypes.txt.meta
  5. 1
      Assets/Fungus/Lua/Resources/Types/RegisterTypes.txt
  6. 7
      Assets/Fungus/Lua/Scripts/Editor/LuaUtilsEditor.cs
  7. 4
      Assets/Fungus/Lua/Scripts/Editor/LuaUtilsEditor.cs.meta
  8. 246
      Assets/Fungus/Lua/Scripts/LuaEnvironment.cs
  9. 304
      Assets/Fungus/Lua/Scripts/LuaUtils.cs
  10. 12
      Assets/Fungus/Lua/Scripts/LuaUtils.cs.meta
  11. 52
      Assets/Tests/Lua/FungusTests.unity
  12. 36
      Assets/Tests/Lua/LuaEnvironmentTests.unity
  13. 0
      Assets/Tests/TestAssets/Resources.meta
  14. 0
      Assets/Tests/TestAssets/Resources/Lua.meta
  15. 0
      Assets/Tests/TestAssets/Resources/Lua/teststringtable.txt
  16. 0
      Assets/Tests/TestAssets/Resources/Lua/teststringtable.txt.meta

26
Assets/Fungus/Lua/Resources/Lua/fungus.txt

@ -17,14 +17,18 @@ end
-- Returns the absolute time
-- Use this timing function to work correctly with the Lua Environment's timeScale property
function M.time()
return unity.luaenvironment.getTime()
function M.gettime()
return unity.luautils.getTime()
end
-- Returns the delta time this frame
-- Use this timing function to work correctly with the Lua Environment's timeScale property
function M.deltatime()
return unity.luaenvironment.getDeltaTime()
function M.getdeltatime()
return unity.luautils.getDeltaTime()
end
function M.settimescale(s)
unity.luautils.timeScale = s
end
-------------
@ -33,8 +37,8 @@ end
-- Waits for a number of seconds
function M.wait(duration)
local t = M.time()
while (M.time() - t < duration) do
local t = M.gettime()
while (M.gettime() - t < duration) do
coroutine.yield()
end
end
@ -43,10 +47,10 @@ end
-- Returns true if the function succeeded, or false if the timeout expired
--
function M.waitfor(fn, timeoutDuration)
local t = M.time()
local t = M.gettime()
while (not fn()) do
coroutine.yield()
if (M.time() - t > timeoutDuration) then
if (M.gettime() - t > timeoutDuration) then
return false
end
end
@ -88,18 +92,18 @@ end
-- Set active language for string table
function M.setlanguage(languageCode)
unity.luaenvironment.activeLanguage = languageCode
unity.luautils.activeLanguage = languageCode
end
-- Get a named string from the string table
function M.getstring(key)
return unity.luaenvironment.GetString(key)
return unity.luautils.GetString(key)
end
-- Substitutes variables and localisation strings into a piece of text
-- e.g. v = 10, "Subbed value is [$v]" => "Subbed value is 10"
function M.sub(text)
return unity.luaenvironment.substitute(text)
return unity.luautils.substitute(text)
end
--------------------

18
Assets/Fungus/Lua/Resources/Prefabs/LuaEnvironment.prefab

@ -9,6 +9,7 @@ GameObject:
m_Component:
- 4: {fileID: 495584}
- 114: {fileID: 11493126}
- 114: {fileID: 11486636}
m_Layer: 0
m_Name: LuaEnvironment
m_TagString: Untagged
@ -28,7 +29,7 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!114 &11493126
--- !u!114 &11486636
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
@ -36,15 +37,26 @@ MonoBehaviour:
m_GameObject: {fileID: 100640}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ba19c26c1ba7243d2b57ebc4329cc7c6, type: 3}
m_Script: {fileID: 11500000, guid: c10f0b861365b42b0928858f7b086ff3, type: 3}
m_Name:
m_EditorClassIdentifier:
remoteDebugger: 0
stringTable: {fileID: 0}
activeLanguage: en
timeScale: -1
registerTypes:
- {fileID: 4900000, guid: 9c3ab7a98d51241bbb499643399fa761, type: 3}
--- !u!114 &11493126
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100640}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ba19c26c1ba7243d2b57ebc4329cc7c6, type: 3}
m_Name:
m_EditorClassIdentifier:
remoteDebugger: 0
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1

2
Assets/Fungus/Lua/Resources/Types/ExtensionTypes.txt

@ -1,2 +0,0 @@


8
Assets/Fungus/Lua/Resources/Types/ExtensionTypes.txt.meta

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 2978c0ed6806b42629d2bf7d0d1f220c
timeCreated: 1459352238
licenseType: Free
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

1
Assets/Fungus/Lua/Resources/Types/RegisterTypes.txt

@ -19,6 +19,7 @@ Fungus.FloatVariable
Fungus.Flowchart
Fungus.FungusPrefs
Fungus.LuaEnvironment
Fungus.LuaUtils
Fungus.GameObjectVariable
Fungus.IntegerVariable
Fungus.Label

7
Assets/Fungus/Lua/Scripts/Editor/LuaEnvironmentEditor.cs → Assets/Fungus/Lua/Scripts/Editor/LuaUtilsEditor.cs

@ -8,10 +8,9 @@ using System.Reflection;
using System.IO;
namespace Fungus
{
[CustomEditor (typeof(LuaEnvironment))]
public class LuaEnvironmentEditor : Editor
{
[CustomEditor (typeof(LuaUtils))]
public class LuaUtilsEditor : Editor
{
protected SerializedProperty registerTypesProp;
protected ReorderableList registerTypeList;

4
Assets/Fungus/Lua/Scripts/Editor/LuaEnvironmentEditor.cs.meta → Assets/Fungus/Lua/Scripts/Editor/LuaUtilsEditor.cs.meta

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 4fba065af9c124bbd837138d28ac0cab
timeCreated: 1459508303
guid: 2e8bbf4afc9f447ccb83004b8bbe3e1a
timeCreated: 1459521262
licenseType: Free
MonoImporter:
serializedVersion: 2

246
Assets/Fungus/Lua/Scripts/LuaEnvironment.cs

@ -96,33 +96,6 @@ namespace Fungus
[Tooltip("Launches the remote Lua debugger in your browser and breaks execution at the first executed Lua command.")]
public bool remoteDebugger = false;
/// <summary>
/// Lua script file which defines the global string table used for localisation.
/// </summary>
[Tooltip("Lua script file which defines the global string table used for localisation.")]
public TextAsset stringTable;
/// <summary>
/// The currently selected language in the string table. Affects variable substitution.
/// </summary>
[Tooltip("The currently selected language in the string table. Affects variable substitution.")]
public string activeLanguage = "en";
/// <summary>
/// Time scale factor to apply when running Lua scripts.
/// This allows pausing of time based operations by setting timescale to 0.
/// Use the GetTime() and GetDeltaTime() functions to get scaled time values.
/// If negative, then GetTime() and GetDeltaTime() return the same values as the standard Time class.
/// </summary>
[Tooltip("Time scale factor to apply when running Lua scripts. If negative then uses the same values as the standard Time class.")]
public float timeScale = -1f;
/// <summary>
/// A text file listing the c# types that can be accessed from Lua.
/// </summary>
[HideInInspector]
public List<TextAsset> registerTypes = new List<TextAsset>();
/// <summary>
/// Instance of remote debugging service when debugging option is enabled.
/// </summary>
@ -133,12 +106,7 @@ namespace Fungus
/// </summary>
protected bool initialised = false;
/// <summary>
/// Cached referenence to the string table (if loaded).
/// </summary>
protected Table stringTableCached;
protected virtual void Start()
protected virtual void Start()
{
InitInterpreter();
}
@ -160,10 +128,13 @@ namespace Fungus
interpreter = new Script(CoreModules.Preset_Complete);
InitLuaScriptFiles();
InitTypes();
InitCustomObjects();
InitBindings();
InitStringTable();
// TODO: Use an interface here instead
LuaUtils luaUtils = GetComponent<LuaUtils>();
if (luaUtils != null)
{
luaUtils.Initialise();
}
if (remoteDebugger)
{
@ -182,35 +153,6 @@ namespace Fungus
interpreter.Options.ScriptLoader = new LuaScriptLoader(result.OfType<TextAsset>());
}
/// <summary>
/// Registers all listed c# types for interop with Lua.
/// You can also register types directly in the Awake method of any
/// monobehavior in your scene using UserData.RegisterType() directly.
/// </summary>
protected virtual void InitTypes()
{
// Register types
foreach (TextAsset textFile in registerTypes)
{
if (textFile == null)
{
continue;
}
char[] separators = { '\r', '\n' };
foreach (string typeName in textFile.text.Split(separators, StringSplitOptions.RemoveEmptyEntries))
{
// Skip comments and empty lines
if (typeName.StartsWith("#") || typeName.Trim() == "")
{
continue;
}
RegisterType(typeName);
}
}
}
/// <summary>
/// Register a type given it's assembly qualified name.
/// </summary>
@ -250,178 +192,6 @@ namespace Fungus
}
}
/// <summary>
/// Register some commonly used Unity classes and objects for Lua interop.
/// To register more class objects externally to this class, register them in the Awake method of any
/// monobehavior in your scene.
/// </summary>
protected virtual void InitCustomObjects()
{
// Add the CLR class objects to a global unity table
Table unityTable = new Table(interpreter);
interpreter.Globals["unity"] = unityTable;
// Static classes
unityTable["time"] = UserData.CreateStatic(typeof(Time));
unityTable["fungusprefs"] = UserData.CreateStatic(typeof(FungusPrefs));
UserData.RegisterType(typeof(PODTypeFactory));
unityTable["factory"] = UserData.CreateStatic(typeof(PODTypeFactory));
// This Lua Environment component
unityTable["luaenvironment"] = this;
// Provide access to the Unity Test Tools (if available).
Type testType = Type.GetType("IntegrationTest");
if (testType != null)
{
UserData.RegisterType(testType);
unityTable["test"] = UserData.CreateStatic(testType);
}
// Example of how to register an enum
// UserData.RegisterType<MyClass.MyEnum>();
// interpreter.Globals.Set("MyEnum", UserData.CreateStatic<MyClass.MyEnum>());
}
/// <summary>
/// Binds all gameobjects and components defined in scene LuaBindings to the global table.
/// </summary>
protected virtual void InitBindings()
{
LuaBindingsBase[] bindings = GameObject.FindObjectsOfType<LuaBindingsBase>();
foreach (LuaBindingsBase binding in bindings)
{
binding.AddBindings(interpreter.Globals);
}
}
/// <summary>
/// Loads the global string table used for localisation.
/// </summary>
protected virtual void InitStringTable()
{
if (stringTable != null)
{
try
{
DynValue stringTableRes = interpreter.DoString(stringTable.text);
if (stringTableRes.Type == DataType.Table)
{
stringTableCached = stringTableRes.Table;
interpreter.Globals["stringtable"] = stringTableCached;
}
}
catch (ScriptRuntimeException ex)
{
UnityEngine.Debug.LogError("Lua runtime error: " + ex.DecoratedMessage);
}
catch (InterpreterException ex)
{
UnityEngine.Debug.LogError(ex.DecoratedMessage);
}
}
}
/// <summary>
/// Returns a string from the string table for this key.
/// The string returned depends on the active language.
/// </summary>
public virtual string GetString(string key)
{
if (stringTableCached != null)
{
// Match against string table and active language
DynValue stringTableVar = stringTableCached.Get(key);
if (stringTableVar.Type == DataType.Table)
{
DynValue languageEntry = stringTableVar.Table.Get(activeLanguage);
if (languageEntry.Type == DataType.String)
{
return languageEntry.String;
}
}
}
return "";
}
/// <summary>
/// Substitutes specially formatted tokens in the text with global variables and string table values.
/// The string table value used depends on the currently loaded string table and active language.
/// </summary>
public virtual string Substitute(string text)
{
string subbedText = text;
// Instantiate the regular expression object.
Regex r = new Regex("\\[\\$.*?\\]");
// Match the regular expression pattern against a text string.
var results = r.Matches(text);
foreach (Match match in results)
{
string key = match.Value.Substring(2, match.Value.Length - 3);
if (stringTableCached != null)
{
// Match against string table and active language
DynValue stringTableVar = stringTableCached.Get(key);
if (stringTableVar.Type == DataType.Table)
{
DynValue languageEntry = stringTableVar.Table.Get(activeLanguage);
if (languageEntry.Type == DataType.String)
{
subbedText = subbedText.Replace(match.Value, languageEntry.String);
}
continue;
}
}
// Match against global variables
DynValue globalVar = interpreter.Globals.Get(key);
if (globalVar.Type != DataType.Nil)
{
subbedText = subbedText.Replace(match.Value, globalVar.ToPrintString());
continue;
}
}
return subbedText;
}
/// <summary>
/// Returns the time since level load, multiplied by timeScale.
/// If timeScale is negative then returns the same as Time.timeSinceLevelLoaded.
/// </summary>
public float GetTime()
{
if (timeScale < 0f)
{
return Time.timeSinceLevelLoad;
}
else
{
return Time.unscaledTime * timeScale;
}
}
/// <summary>
/// Returns the delta time this frame, multiplied by timeScale.
/// If timeScale is negative then returns the same as Time.deltaTime.
/// </summary>
public float GetDeltaTime()
{
if (timeScale < 0f)
{
return Time.deltaTime;
}
else
{
return Time.deltaTime * timeScale;
}
}
/// <summary>
/// Load and run a string containing Lua script. May be run as a coroutine.
/// <param name="luaString">The Lua code to be run.</param>

304
Assets/Fungus/Lua/Scripts/LuaUtils.cs

@ -0,0 +1,304 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Diagnostics;
using System.Text.RegularExpressions;
using MoonSharp.Interpreter;
using MoonSharp.Interpreter.Interop;
using MoonSharp.Interpreter.Loaders;
using MoonSharp.RemoteDebugger;
namespace Fungus
{
public class LuaUtils : MonoBehaviour
{
/// <summary>
/// Lua script file which defines the global string table used for localisation.
/// </summary>
[Tooltip("Lua script file which defines the global string table used for localisation.")]
public TextAsset stringTable;
/// <summary>
/// The currently selected language in the string table. Affects variable substitution.
/// </summary>
[Tooltip("The currently selected language in the string table. Affects variable substitution.")]
public string activeLanguage = "en";
/// <summary>
/// Time scale factor to apply when running Lua scripts.
/// This allows pausing of time based operations by setting timescale to 0.
/// Use the GetTime() and GetDeltaTime() functions to get scaled time values.
/// If negative, then GetTime() and GetDeltaTime() return the same values as the standard Time class.
/// </summary>
[Tooltip("Time scale factor to apply when running Lua scripts. If negative then uses the same values as the standard Time class.")]
public float timeScale = -1f;
/// <summary>
/// A text file listing the c# types that can be accessed from Lua.
/// </summary>
[HideInInspector]
public List<TextAsset> registerTypes = new List<TextAsset>();
/// <summary>
/// Flag used to avoid startup dependency issues.
/// </summary>
protected bool initialised = false;
/// <summary>
/// Cached reference to the string table (if loaded).
/// </summary>
protected Table stringTableCached;
/// <summary>
/// Cached reference to the Lua Environment component.
/// </summary>
protected LuaEnvironment luaEnvironment;
public virtual void Initialise()
{
luaEnvironment = GetComponent<LuaEnvironment>();
if (luaEnvironment == null)
{
UnityEngine.Debug.LogError("No Lua Environment found");
return;
}
if (luaEnvironment.Interpreter == null)
{
UnityEngine.Debug.LogError("No Lua interpreter found");
return;
}
InitTypes();
InitBindings();
InitCustomObjects();
InitStringTable();
}
/// <summary>
/// Registers all listed c# types for interop with Lua.
/// You can also register types directly in the Awake method of any
/// monobehavior in your scene using UserData.RegisterType().
/// </summary>
protected virtual void InitTypes()
{
foreach (TextAsset textFile in registerTypes)
{
if (textFile == null)
{
continue;
}
char[] separators = { '\r', '\n' };
foreach (string typeName in textFile.text.Split(separators, StringSplitOptions.RemoveEmptyEntries))
{
// Skip comments and empty lines
if (typeName.StartsWith("#") || typeName.Trim() == "")
{
continue;
}
LuaEnvironment.RegisterType(typeName);
}
}
}
/// <summary>
/// Binds all gameobjects and components defined in scene LuaBindings to the global table.
/// </summary>
protected virtual void InitBindings()
{
MoonSharp.Interpreter.Script interpreter = luaEnvironment.Interpreter;
LuaBindingsBase[] bindings = GameObject.FindObjectsOfType<LuaBindingsBase>();
foreach (LuaBindingsBase binding in bindings)
{
binding.AddBindings(interpreter.Globals);
}
}
/// <summary>
/// Register some commonly used Unity classes and objects for Lua interop.
/// To register more class objects externally to this class, register them in the Awake method of any
/// monobehavior in your scene.
/// </summary>
protected virtual void InitCustomObjects()
{
MoonSharp.Interpreter.Script interpreter = luaEnvironment.Interpreter;
// Add the CLR class objects to a global unity table
Table unityTable = new Table(interpreter);
interpreter.Globals["unity"] = unityTable;
// Static classes
unityTable["time"] = UserData.CreateStatic(typeof(Time));
unityTable["fungusprefs"] = UserData.CreateStatic(typeof(FungusPrefs));
UserData.RegisterType(typeof(PODTypeFactory));
unityTable["factory"] = UserData.CreateStatic(typeof(PODTypeFactory));
// Lua Environment and Lua Utils components
unityTable["luaenvironment"] = luaEnvironment;
unityTable["luautils"] = this;
// Provide access to the Unity Test Tools (if available).
Type testType = Type.GetType("IntegrationTest");
if (testType != null)
{
UserData.RegisterType(testType);
unityTable["test"] = UserData.CreateStatic(testType);
}
// Example of how to register an enum
// UserData.RegisterType<MyClass.MyEnum>();
// interpreter.Globals.Set("MyEnum", UserData.CreateStatic<MyClass.MyEnum>());
}
/// <summary>
/// Loads the global string table used for localisation.
/// </summary>
protected virtual void InitStringTable()
{
MoonSharp.Interpreter.Script interpreter = luaEnvironment.Interpreter;
if (stringTable != null)
{
try
{
DynValue stringTableRes = interpreter.DoString(stringTable.text);
if (stringTableRes.Type == DataType.Table)
{
stringTableCached = stringTableRes.Table;
interpreter.Globals["stringtable"] = stringTableCached;
}
}
catch (ScriptRuntimeException ex)
{
UnityEngine.Debug.LogError("Lua runtime error: " + ex.DecoratedMessage);
}
catch (InterpreterException ex)
{
UnityEngine.Debug.LogError(ex.DecoratedMessage);
}
}
}
/// <summary>
/// Returns a string from the string table for this key.
/// The string returned depends on the active language.
/// </summary>
public virtual string GetString(string key)
{
if (stringTableCached != null)
{
// Match against string table and active language
DynValue stringTableVar = stringTableCached.Get(key);
if (stringTableVar.Type == DataType.Table)
{
DynValue languageEntry = stringTableVar.Table.Get(activeLanguage);
if (languageEntry.Type == DataType.String)
{
return languageEntry.String;
}
}
}
return "";
}
/// <summary>
/// Substitutes specially formatted tokens in the text with global variables and string table values.
/// The string table value used depends on the currently loaded string table and active language.
/// </summary>
public virtual string Substitute(string text)
{
if (luaEnvironment == null)
{
UnityEngine.Debug.LogError("No Lua Environment found");
return text;
}
if (luaEnvironment.Interpreter == null)
{
UnityEngine.Debug.LogError("No Lua interpreter found");
return text;
}
MoonSharp.Interpreter.Script interpreter = luaEnvironment.Interpreter;
string subbedText = text;
// Instantiate the regular expression object.
Regex r = new Regex("\\[\\$.*?\\]");
// Match the regular expression pattern against a text string.
var results = r.Matches(text);
foreach (Match match in results)
{
string key = match.Value.Substring(2, match.Value.Length - 3);
// Match against string table and active language (if specified)
if (stringTableCached != null)
{
DynValue stringTableVar = stringTableCached.Get(key);
if (stringTableVar.Type == DataType.Table)
{
DynValue languageEntry = stringTableVar.Table.Get(activeLanguage);
if (languageEntry.Type == DataType.String)
{
subbedText = subbedText.Replace(match.Value, languageEntry.String);
}
continue;
}
}
// Match against global variables
DynValue globalVar = interpreter.Globals.Get(key);
if (globalVar.Type != DataType.Nil)
{
subbedText = subbedText.Replace(match.Value, globalVar.ToPrintString());
continue;
}
}
return subbedText;
}
/// <summary>
/// Returns the time since level load, multiplied by timeScale.
/// If timeScale is negative then returns the same as Time.timeSinceLevelLoaded.
/// </summary>
public float GetTime()
{
if (timeScale < 0f)
{
return Time.timeSinceLevelLoad;
}
else
{
return Time.unscaledTime * timeScale;
}
}
/// <summary>
/// Returns the delta time this frame, multiplied by timeScale.
/// If timeScale is negative then returns the same as Time.deltaTime.
/// </summary>
public float GetDeltaTime()
{
if (timeScale < 0f)
{
return Time.deltaTime;
}
else
{
return Time.deltaTime * timeScale;
}
}
}
}

12
Assets/Fungus/Lua/Scripts/LuaUtils.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c10f0b861365b42b0928858f7b086ff3
timeCreated: 1459515524
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

52
Assets/Tests/Lua/FungusTests.unity

@ -127,7 +127,51 @@ MonoBehaviour:
m_EditorClassIdentifier:
tableName:
registerTypes: 1
boundTypes: []
boundTypes:
- UnityEngine.GameObject, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.PrimitiveType, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.Component, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- UnityEngine.SendMessageOptions, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
- UnityEngine.SceneManagement.Scene, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
- UnityEngine.Object, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- System.Single, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- Fungus.SayDialog, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.AudioClip, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- System.Action, System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- Fungus.Character, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- Fungus.Flowchart, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.Sprite, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.Color, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.UI.Button, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.Canvas, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.UI.Text, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.UI.Image, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
- Fungus.FacingDirection, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- Fungus.PortraitState, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.TextGenerator, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.Texture, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.Font, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.TextAnchor, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.HorizontalWrapMode, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
- UnityEngine.VerticalWrapMode, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.FontStyle, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.TextGenerationSettings, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
- UnityEngine.Vector2, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.AudioClipLoadType, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
- UnityEngine.AudioDataLoadState, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
- UnityEngine.AudioClip+PCMReaderCallback, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
- UnityEngine.AudioClip+PCMSetPositionCallback, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
boundObjects:
- key: saydialog
obj: {fileID: 2087053783}
@ -1114,7 +1158,7 @@ MonoBehaviour:
fungus.assert (s.value == "a string")
t = fungus.time()
t = fungus.gettime()
-- Execute a block to change the variable
@ -1124,7 +1168,7 @@ MonoBehaviour:
fungus.runwait( b.Execute() )
fungus.assert(fungus.time() - t >= 1)
fungus.assert(fungus.gettime() - t >= 1)
-- Check the new value of StringVar
@ -8202,7 +8246,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &1738857301
MonoBehaviour:
m_ObjectHideFlags: 0

36
Assets/Tests/Lua/LuaEnvironmentTests.unity

@ -288,10 +288,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
tableName:
boundObjects:
- key: dummycollection
obj: {fileID: 367860753}
component: {fileID: 367860754}
registerTypes: 1
boundTypes:
- UnityEngine.GameObject, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.PrimitiveType, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
@ -307,6 +304,10 @@ MonoBehaviour:
- System.Single, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- Fungus.DummyCollection, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- UnityEngine.Sprite, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
boundObjects:
- key: dummycollection
obj: {fileID: 367860753}
component: {fileID: 367860754}
--- !u!1 &305346650
GameObject:
m_ObjectHideFlags: 0
@ -357,10 +358,10 @@ MonoBehaviour:
luaEnvironment: {fileID: 0}
luaFile: {fileID: 0}
luaScript: "-- Test the timeout works in fungus.waitfor\nlocal value = false\n\nfunction
fn()\n return value\nend\n\nt = fungus.time()\nfungus.waitfor(fn, 1)\nfungus.assert
(fungus.time() - t >= 1)\n\n-- Test fungus.waitfor() exits if the function returns
true\n-- If this doesn't work the test will timeout and fail\nvalue = true\nfungus.waitfor(fn,
1)\n\nfungus.pass()"
fn()\n return value\nend\n\nt = fungus.gettime()\nfungus.waitfor(fn, 1)\nfungus.assert
(fungus.gettime() - t >= 1)\n\n-- Test fungus.waitfor() exits if the function
returns true\n-- If this doesn't work the test will timeout and fail\nvalue =
true\nfungus.waitfor(fn, 1)\n\nfungus.pass()"
runAsCoroutine: 1
useFungusModule: 1
--- !u!1001 &364012152
@ -477,7 +478,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!114 &637150168
MonoBehaviour:
m_ObjectHideFlags: 0
@ -829,11 +830,11 @@ MonoBehaviour:
-- Should take 1 second in realtime to wait for 1 second
t= fungus.time()
t = fungus.gettime()
fungus.wait(1)
t = fungus.time() - t
t = fungus.gettime() - t
fungus.assert(t >= 1)
@ -842,13 +843,13 @@ MonoBehaviour:
-- Should take 2 seconds in realtime to wait for 1 second
unity.luaenvironment.timeScale = 0.5
fungus.settimescale(0.5)
t= fungus.time()
t = fungus.gettime()
fungus.wait(1)
t = fungus.time() - t
t = fungus.gettime() - t
fungus.assert(t >= 1)
@ -1332,6 +1333,7 @@ MonoBehaviour:
luaFile: {fileID: 0}
luaScript: '-- Test string table localisation system
print(stringtable)
fungus.assert(stringtable != nil)
@ -1479,6 +1481,10 @@ Prefab:
propertyPath: stringTable
value:
objectReference: {fileID: 4900000, guid: 9900570d789fa4b29957e4b897af9e3b, type: 3}
- target: {fileID: 11486636, guid: 49031c561e16d4fcf91c12153f8e0b25, type: 2}
propertyPath: stringTable
value:
objectReference: {fileID: 4900000, guid: 9900570d789fa4b29957e4b897af9e3b, type: 3}
m_RemovedComponents:
- {fileID: 11403674, guid: 49031c561e16d4fcf91c12153f8e0b25, type: 2}
m_ParentPrefab: {fileID: 100100000, guid: 49031c561e16d4fcf91c12153f8e0b25, type: 2}
@ -1502,7 +1508,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &1900871525
MonoBehaviour:
m_ObjectHideFlags: 0

0
Assets/Tests/Resources.meta → Assets/Tests/TestAssets/Resources.meta

0
Assets/Tests/Resources/Lua.meta → Assets/Tests/TestAssets/Resources/Lua.meta

0
Assets/Tests/Resources/Lua/teststringtable.txt → Assets/Tests/TestAssets/Resources/Lua/teststringtable.txt

0
Assets/Tests/Resources/Lua/teststringtable.txt.meta → Assets/Tests/TestAssets/Resources/Lua/teststringtable.txt.meta

Loading…
Cancel
Save