I made a process of adding the in-game editor to any game or application easy by simply adding a few lines to a CMakeLists.txt.
Using 19 vehicle demo as an example:
# Define target name
set (TARGET_NAME 19_VehicleDemo)
# Define source files
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
#=================
# BEG: in-game editor
#=================
include_directories ( ../../Tools/InGameEditor/Source )
include_directories ( ../../Tools/InGameEditor/Source/UI )
file (GLOB IGE_CPP_FILES ../../Tools/InGameEditor/Source/*.cpp ../../Tools/InGameEditor/Source/UI/*.cpp )
file (GLOB IGE_H_FILES ../../Tools/InGameEditor/Source/*.h ../../Tools/InGameEditor/Source/UI/*.h )
source_group ("Source Files\\InGameEditor" FILES ${IGE_CPP_FILES})
source_group ("Header Files\\InGameEditor" FILES ${IGE_H_FILES})
### set ###
set (SOURCE_FILES ${CPP_FILES} ${H_FILES} ${IGE_CPP_FILES} ${IGE_H_FILES})
#=================
# END
#=================
# Setup target with resource copying
if (EMSCRIPTEN)
# Override the Urho3D default
math (EXPR EMSCRIPTEN_TOTAL_MEMORY "64 * 1024 * 1024")
if (URHO3D_TESTING AND URHO3D_TEST_TIMEOUT LESS 15)
set (URHO3D_TEST_TIMEOUT 15)
endif ()
endif ()
setup_main_executable ()
# Setup test cases
setup_test ()
The in-game editor code is built with whatever game you add to it. It’s not a stand alone lib/so/dll that you link with.
There are changes that you need to add to your game code:
Add:
// 1) add to your constructor
RegisterInGameEditor(context);
// 2) add after you've created the game scene
context_->RegisterSubsystem(new InGameEditor(context_));
GetSubsystem<InGameEditor>()->SetGlobalScene( scene_ );
// 3) in your HandleUpdate(...) func.
if ( GetSubsystem<InGameEditor>()->IsVisible() ) return;
That’s it. Very simple process.
Here’s the outcome:
Comments and/or feedback welcome.