Browse Source

When editor is run from Urho3DPlayer, enable Lua if possible to allow editing Lua scripted scenes. Closes #294.

Lasse Öörni 11 years ago
parent
commit
2ac921de60

+ 1 - 1
Bin/Data/Scripts/Editor/AttributeEditor.as

@@ -25,7 +25,7 @@ String sceneResourcePath = AddTrailingSlash(fileSystem.programDir + "Data");
 bool rememberResourcePath = true;
 
 // Exceptions for string attributes that should not be continuously edited
-Array<String> noTextChangedAttrs = {"Class Name", "Script Object Type"};
+Array<String> noTextChangedAttrs = {"Script File", "Class Name", "Script Object Type", "Script File Name"};
 
 WeakHandle testAnimState;
 

+ 4 - 0
Bin/Data/UI/EditorIcons.xml

@@ -107,6 +107,10 @@
         <attribute name="Texture" value="Texture2D;Textures/Editor/EditorIcons.png" />
         <attribute name="Image Rect" value="64 0 78 14" />
     </element>
+    <element type="LuaScriptInstance">
+        <attribute name="Texture" value="Texture2D;Textures/Editor/EditorIcons.png" />
+        <attribute name="Image Rect" value="64 0 78 14" />
+    </element>
     <element type="Skybox">
         <attribute name="Texture" value="Texture2D;Textures/Editor/EditorIcons.png" />
         <attribute name="Image Rect" value="16 16 30 30" />

+ 8 - 0
Source/Tools/Urho3DPlayer/Urho3DPlayer.cpp

@@ -129,6 +129,14 @@ void Urho3DPlayer::Start()
         // Hold a shared pointer to the script file to make sure it is not unloaded during runtime
         scriptFile_ = GetSubsystem<ResourceCache>()->GetResource<ScriptFile>(scriptFileName_);
 
+        /// \hack If we are running the editor, also instantiate Lua subsystem to enable editing Lua ScriptInstances
+#ifdef ENABLE_LUA
+        if (scriptFileName_.Contains("Editor.as", false))
+        {
+            LuaScript* luaScript = new LuaScript(context_);
+            context_->RegisterSubsystem(luaScript);
+        }
+#endif
         // If script loading is successful, proceed to main loop
         if (scriptFile_ && scriptFile_->Execute("void Start()"))
         {