Browse Source

Add properties to control LuaEnvironment debug server

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

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

@ -16,6 +16,12 @@ namespace Fungus
/// </summary>
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>
/// The MoonSharp interpreter instance.
/// </summary>
@ -112,18 +118,6 @@ namespace Fungus
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>
/// Writes a MoonSharp exception to the debug log in a helpful format.
/// </summary>
@ -263,12 +257,20 @@ namespace Fungus
//
// Change this to #if UNITY_STANDALONE if you want to debug a standalone build.
//
#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
DebugServer.AttachToScript(interpreter, gameObject.name);
}
// Attach the MoonSharp script to the debugger
DebugServer.AttachToScript(interpreter, gameObject.name);
#endif
initialised = true;

Loading…
Cancel
Save