Dreikblack Posted January 18 Share Posted January 18 If i just use component with saved scene from Load() everything works. But if i save entity as prefab, scene will expire. Most likely it's due scene in Load is Prefab's scene - scene->navmeshes is empty for prefab component in Load when real scene have it. Component and its prefab example TestPrefab.zip Quote Link to comment Share on other sites More sharing options...
Josh Posted January 23 Share Posted January 23 This is by design. The prefab has a temporary scene all entities are loaded into, which allows each component to retrieve the objects in that prefab. What happens if you move the navmesh code into the first call to the Update() method? Something like this: class component { std::weak_ptr<Scene> scene; } void component::Update() { auto scene = this->scene.lock(); if (not scene) { scene = MyGame->scene; this->scene = scene; if (scene and not scene->navmeshes.empty()) { //do some things here... } } } Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted January 24 Author Share Posted January 24 3 hours ago, Josh said: scene = MyGame->scene; This is something that i can do in my game by using Singletones, but it's not proper option for components to share in Downloads or tutorials. 3 hours ago, Josh said: component to retrieve the objects in that prefab. Which should be possible via kids of root entity and normal scene anyway? Quote Link to comment Share on other sites More sharing options...
Dreikblack Posted January 24 Author Share Posted January 24 And if it's needed internally can be normal scene be send to component Load() since it's called per instance anyway? Quote Link to comment Share on other sites More sharing options...
Josh Posted January 24 Share Posted January 24 2 hours ago, Dreikblack said: This is something that i can do in my game by using Singletones, but it's not proper option for components to share in Downloads or tutorials. Which should be possible via kids of root entity and normal scene anyway? Not exactly. Prefabs have a UUID for each entity, but since there can be multiple prefabs of the same file loaded, a new UUID is generated when the prefab gets added to the main scene. It's messy. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted January 24 Author Share Posted January 24 Maybe something like std::list<std::weak_ptr<Scene>> scenes; can be added to World? Quote Link to comment Share on other sites More sharing options...
Josh Posted January 24 Share Posted January 24 I am going to leave this open because I want to think about it more. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.