How to run specific collection?

Problem: run selected/specified collection as bootstrap without interfering to main.collection.

Found a bunch of topics, most recent was 2 years ago.

My current approach is using bob:

  1. make build to apply changes.
bob --variant=debug
  1. make binary executable
chmod +x build/x86_64-linux/dmengine
  1. finally tell dmengine to override bootstap and run!
build/x86_64-linux/dmengine --config=bootstrap.main_collection=/collections/tests.collectionc

But here is 2 problems:

  1. dmengine can’t run collection that doesn’t exists, so you must inlcude tests.collection into main.collection (for example as collection proxy)
  2. you have to run 3 commands each time when you change something (which can be automated) and wait around 2 seconds each time (hello unity!)

Maybe someone have different approach?

  1. To include tests.collection (or anything else) in the bundle without referencing it somewhere, you can declare it as a custom resource in game.project, in the “Project” category.
  2. Are you bundling the game every time you make a change to it, maybe because you want to test it without Defold’s profiler and all? Or do you want to test different collections without changing the value in the game.project file because you might forget to change it back?

My approach is to have two collection proxies in main.collection and use a script to determine which collection is played. It would look like this. It follows the “loader” pattern described in the Collection Proxy manual.

go.property('play_debug_collection', false)

function init(self)
	if sys.get_engine_info().is_debug and self.play_debug_collection then
		msg.post('#tests', 'load')
	else
		msg.post('#start game', 'load')
	end
end

function on_message(self, message_id, message, sender)
	if message_id == hash('proxy_loaded') then
		msg.post(sender, 'init')
		msg.post(sender, 'enable')
	end
end

Then the file path and toggle belong to main.collection instead of in game.project, and the debug collection won’t be accidentally loaded in a release build.