elix22/Urho3D

Lookup of deserialized scenes cannot find Children/Component of managed components

Closed this issue · 3 comments

If loading a scene in which you have managed c# components (like e.g. in the VehicleDemo with its Vehicle-Component) those cannot be queried after loading the scene via scene.LoadXml(...)
Taking VehicleDemo as example. The scene is created in VehicleDemo.CreateScene() and queries like:
var componentBefore = scene.GetComponent<Vehicle>(true);
var childrenBefore = scene.GetChildrenWithComponent<Vehicle>(true);
Do result in the expected result!
Saving the scene and loading it, afterwards same calls result in null/empty-results. You can query for those Nodes via cpp-components (e.g. StaticMesh...) as usual and it works, and once you have the specific node you can also get the managed-component.

I want to fix the 'recursive'-lookup-calls, but I'm not completely sure what the best setup would be to test whats going on in the c#-glue-layer. Do you have a suggestion how to setup the the project so that I can work on the cs-files (Dotnet/Binding/...) instead of the UrhoDotNet.dll so that I can debug and maybe better understand what is going on under the hood.

PS:
I saw the Urho.Shared.projitems which seems to be something that I would need to include but I'm pretty clueless about csproj-files and how they work.

Yes , I am aware of this issue , it's in my todo list of fixes
Actually I implemented an hack that actually works (it's not so efficient but it works) , see link below
https://github.com/Urho-Net/Samples/blob/main/HotReload/Source/DynamicComponentManager.cs#L275
Calling : var children = GetChildrenWithComponent(typeof(Vehicle)); will do the job

I personally haven't concluded yet a final optimized solution for that
If you want to fix it , my hack might be a starting reference point.
P.S. I fixed the VehicleDemo , now it loads and saves the scene.

Sorry I can't help you with the setup of a debug project , I don't have one
I personally use Log.Info() (Urho.IO) in various points of interest

OK , I fixed this specific one
cddeaf5

I will include it as part of my next Urho.Net binaries
Let me know if it solves your issues

Thx a lot, you are the best 👍