What happened if i not release input focus? Object will be leak?
function final(self)
-- Return input focus when the object is deleted
msg.post(".", "release_input_focus")
end
What happened if i not release input focus? Object will be leak?
function final(self)
-- Return input focus when the object is deleted
msg.post(".", "release_input_focus")
end
I don’t believe the object will leak and I believe the input focus will be released automatically when the script component is deleted.
It should be easy to test: There is a limit of 16 game objects that can have input focus at a time. Spawn 16 game objects and have a script that acquires input but never releases it. Then delete the game objects and spawn 16 new ones. If there’s a bug and we do not release input then you’d see it immediately as a warning in the console.
I make test all work correct. So when object deletes it is automaticaly remove input. In tutorial http://www.defold.com/tutorials/getting-started/#_step_4_creating_a_hero_character script contains that lines:
function final(self)
-- Return input focus when the object is deleted
msg.post(".", "release_input_focus")
end
So i think that i should do it.
Personally I prefer to be explicit about it, but you’re right, it’s not really needed (and I think I’ll reconsider doing an explicit release_input_focus from now on).