You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
9 years ago
|
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();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|