Chris Gregan
9 years ago
3 changed files with 67 additions and 7 deletions
@ -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(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: db0946039407442029cadd010a2a7a80 |
||||
timeCreated: 1463763860 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
Loading…
Reference in new issue