Browse Source

Add properties to control LuaEnvironment debug server

master
Christopher 8 years ago
parent
commit
798f2458cf
  1. 30
      Assets/Fungus/Thirdparty/FungusLua/Scripts/Components/LuaEnvironment.cs

30
Assets/Fungus/Thirdparty/FungusLua/Scripts/Components/LuaEnvironment.cs vendored

@ -16,6 +16,12 @@ namespace Fungus
/// </summary> /// </summary>
public class LuaEnvironment : MonoBehaviour public class LuaEnvironment : MonoBehaviour
{ {
[Tooltip("Start a Lua debug server on scene start.")]
[SerializeField] protected bool startDebugServer = true;
[Tooltip("Port to use for the Lua debug server.")]
[SerializeField] protected int debugServerPort = 41912;
/// <summary> /// <summary>
/// The MoonSharp interpreter instance. /// The MoonSharp interpreter instance.
/// </summary> /// </summary>
@ -112,18 +118,6 @@ namespace Fungus
yield return StartCoroutine(coroutine); yield return StartCoroutine(coroutine);
} }
protected virtual void StartVSCodeDebugger()
{
if (DebugServer == null)
{
// Create the debugger server
DebugServer = new MoonSharpVsCodeDebugServer();
// Start the debugger server
DebugServer.Start();
}
}
/// <summary> /// <summary>
/// Writes a MoonSharp exception to the debug log in a helpful format. /// Writes a MoonSharp exception to the debug log in a helpful format.
/// </summary> /// </summary>
@ -263,12 +257,20 @@ namespace Fungus
// //
// Change this to #if UNITY_STANDALONE if you want to debug a standalone build. // Change this to #if UNITY_STANDALONE if you want to debug a standalone build.
// //
#if UNITY_EDITOR #if UNITY_EDITOR
StartVSCodeDebugger(); if (startDebugServer &&
DebugServer == null)
{
// Create the debugger server
DebugServer = new MoonSharpVsCodeDebugServer(debugServerPort);
// Start the debugger server
DebugServer.Start();
// Attach the MoonSharp script to the debugger // Attach the MoonSharp script to the debugger
DebugServer.AttachToScript(interpreter, gameObject.name); DebugServer.AttachToScript(interpreter, gameObject.name);
}
#endif #endif
initialised = true; initialised = true;

Loading…
Cancel
Save