This question pertains to using ResourceCache.GetTempResource() from C#. Even though you all work with the C++ version, I’m hoping you can shed some light on this.
I’ve recently realized that if you modify a resource obtained from the ResourceCache using something like:
component.Model = ResourceCache.GetModel(“Models/UVSphere.mdl”);
and then modify it, others that get the same thing from the resource cache will also get that change.
So I need to get a unique copy.
It seems one possible solution is to use Clone() after getting the resource, but for some reason, Clone() is giving me grief on Windows in UrhoSharp. I suspect it has do do with the thread it is called on and it is going to be a big change to invoke this on the Urho thread.
The other possibility is to use GetTempResource.
component.Model = (Model)ResourceCache.GetTempResource(Model.TypeStatic, “Models/UVSphere.mdl”, false);
This will be easier to implement, assuming it works, but the above code throws a class cast exception saying the Resource returned can’t be cast as a Model. Can anyone explain how this should be used?