Enabling/Disabling things in the editor?

Is there a way to enable/disable components and game objects in the editor? Sometimes I’d like to disable things and then reactivate them through code or other means. I know I can enable/disable in code with msg.post(".", "disable") but it would be nice to do it in the editor as well

I see that the gui elements has it, but I dont see it for normal game objects/components?

1 Like

Correct. We do have a feature request on GitHub to implement this, but it is has not been prioritized yet.

I created a script as a workaround for now:

image

-- set_enabled.script
-- Enables/Disables component or game object on init or reload
go.property("target_url", msg.url("."))
go.property("enabled", true)

local function set_enabled(self)
	if self.enabled == false then
		msg.post(self.target_url, "disable")
	end
end

function init(self) set_enabled(self) end

function on_reload(self) set_enabled(self) end

Just add it to any game object and set any target you want. By default it will affect the current game object.

1 Like