Adam's Lair Forum

game development and casual madness
It is currently 2018/07/17, 07:38

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 2017/10/27, 07:18 
Junior Member
Junior Member

Joined: 2016/01/09, 22:52
Posts: 35
Role: Hobbyist
I have a component which switches to a scene after a collision. The Scene is a public ContentRef<Scene> property which I set through the editor. When I switch back and forth between scenes with this method the Scene state is persisted, for example my player is in the same position. I guess the Scene is not garbage collected because of my reference? Is there a way I can reset or reload the Scene object before switching? Thank you for any advice.


Top
 Profile  
 
PostPosted: 2017/10/28, 13:37 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2053
Location: Germany
Role: Professional
This is expected behavior: Switching the currently active scene does not affect the state of any of the scenes. It's really just a switch - not a command to unload or reload content! You can, however, trigger a reload of the old scene yourself by invoking DisposeLater on the old scene when switching to the new one. That way, you'll force it to reload when switching back to it.

zakila wrote:
I guess the Scene is not garbage collected because of my reference?


Duality doesn't release your content automatically: If you request a Resource, the ContentProvider will keep it ready to be used until you tell it that you don't need it anymore. Requesting the same Resource multiple times without disposing it will not cause leaks - because you're dealing with the same instance - but it won't go away on its own either. To get rid of a loaded Resource, just call Dispose/Later on it and if needed, you can always ask the ContentProvider to remove all content, or retrieve a list of currently loaded content to dispose a select part of it yourself.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2017/10/29, 20:11 
Junior Member
Junior Member

Joined: 2016/01/09, 22:52
Posts: 35
Role: Hobbyist
Ok thanks Adam


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group