Browse Source

LuaScript will reinitialise if modified when playing in editor

master
Christopher 9 years ago
parent
commit
8da1c82878
  1. 51
      Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaScriptEditor.cs
  2. 12
      Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaScriptEditor.cs.meta
  3. 4
      Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaScript.cs

51
Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaScriptEditor.cs vendored

@ -0,0 +1,51 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
[CustomEditor (typeof(LuaScript))]
public class LuaScriptEditor : Editor
{
protected SerializedProperty luaEnvironmentProp;
protected SerializedProperty luaFileProp;
protected SerializedProperty luaScriptProp;
protected SerializedProperty runAsCoroutineProp;
protected virtual void OnEnable()
{
luaEnvironmentProp = serializedObject.FindProperty("luaEnvironment");
luaFileProp = serializedObject.FindProperty("luaFile");
luaScriptProp = serializedObject.FindProperty("luaScript");
runAsCoroutineProp = serializedObject.FindProperty("runAsCoroutine");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField(luaEnvironmentProp);
EditorGUILayout.PropertyField(luaFileProp);
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(luaScriptProp);
if (EditorGUI.EndChangeCheck() &&
EditorApplication.isPlaying)
{
// Reinitialise if the Lua script is changed while running in editor
LuaScript luaScript = target as LuaScript;
luaScript.initialised = false;
}
EditorGUILayout.PropertyField(runAsCoroutineProp);
serializedObject.ApplyModifiedProperties();
}
}
}

12
Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaScriptEditor.cs.meta vendored

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

4
Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaScript.cs vendored

@ -43,7 +43,9 @@ namespace Fungus
protected string friendlyName = "";
protected bool initialised;
// This is public so the editor code can force the component to reinitialise
[NonSerialized]
public bool initialised;
// Stores the compiled Lua code for fast execution later.
protected Closure luaFunction;

Loading…
Cancel
Save