It will be cool, if i can build release and debug variants.Or something like flawors in android. For example when i build debug variant a want to show additional debug ui. Or enable analytics/ads only in release.
What we do here at King is that we have settings such as those you mention as values in a custom section in game.project and at build time we set or remove these values. Something like an additional section in game.project:
[foobar]
enable_debug_ui = 1
And in code we check the value like this:
if tonumber(sys.get_config("debug.enable_debug_ui", 0)) == 1 then
-- show debug ui
end
thanks, look like what i need.
How can you access this property from hooks.editor_script
? The sys
module doesn’t seem to be available in that script.
You could just read the game.project file directly with io, like:
local function get_config(key)
local file = io.open("game.project", "r")
if file then
for line in file:lines() do
local s = string.match(line, key.." =(.*)")
if s then
return tonumber(s) or s
end
end
end
end
local enable_debug_ui = get_config("enable_debug_ui")
If the same key appears in multiple sections, you’d need to filter for that first.
I have game.project
and demo.project
and the build variant property would be read depending on which project file you are building - it specifies a different main collection, different project name, bundle identifier for save-file name, etc. too. Some things like atlases have the same name (so that referencing files don’t all need to be updated like two entirely separate projects to maintain) but different content, so the hooks.editor_script
is where I need to know which variant so I can copy the thing_demo.*
or thing_full.*
file. At the moment the hooks script is where this is defined, and it also copies the right .project
file - but this probably going to cause problems.