-
Notifications
You must be signed in to change notification settings - Fork 997
Conversation
UIElements and Nodes store the paths of the files they were loaded from. LoadJSON presently cannot do that, as it does not have access to its path. Handling with scripting still has some things that need to be decided. Should Node.CreateScriptObject be relative to the Node's path or to the Script's? Likewise, how to handle ScriptInstance's loading of a ResourceRef attribute?
Still remaining: LoadJSON base path handling, deciding what to do with scripts for the base path
Why is this necessary for nodes to store their own path? Is path set by EP_RESOURCE_PATHS broken for you? edit: I'm voting this down, as I'm not in favor of code bloat via nodes maintaining their own path when paths set by EP_RESOURCE_PATHS is more efficient. Provide any info that may be pertinent to your argument. |
Huh, I definetely dislike the part with Set/GetBasePath for serializables. As I understood, it is done to make prefabs work with relative paths. Any chance to reach this in another way? Let's think.... |
Regardless of what happens with this, don't think would want to take this into 1.7, just for the potential risk. |
@Lumak this is to address a different issue from the resource paths -- it is meant to allow you to reference resources from say a scene "bin/Data/Maps/Area1/scene.xml" that are located in the resource directory "Data" (or any other resource directory) that you would normally reference "Maps/Area1/SomeTexture.png" as "./SomeTexture.png" instead. Yes, you could just add "Maps/Area1" as another resource path and then just look for "SomeTexture.png", but if you have multiple areas used at once I would not consider it a tenable solution, as you could only access conflicting resource names from the most recently added area (i.e. you also have Maps/Area2/SomeTexture.png, and the two scenes/prefabs use different textures for that). |
I see. That might be useful to some, but I still prefer the current method. |
@t-artikov I'm working on new Editor since last month. I'm going to check this feature when I switch back to the Urho core. |
c7346fe
to
b46c83f
Compare
6a26075
to
9c7ea24
Compare
Marking this stale since there has been no activity for 30 days. |
I've added relative path support to the ResourceCache. Main changes are nodes now storing their base paths, the mechanism for accessing the base paths, and the addition of a basePath parameter to GetResource functions.
Note that this breaks the existing API -- I added the base path parameter after the filename, before the
bool sendEventOnFailure
. This could be done the other way around, but I feel that it is more logical this way, and encourages users to actually pass a basePath parameter.Also, there are a few things left to do -- JSON loading does not get a base path (see the added
#warning
notes), and how it is handled with scripts also needs to be decided -- is it relative to the script instances's path or to the node that hold's the instance? (See the added//TODO:
comments).Also, the actual resolving of the relative paths onto the base path may not be as efficient as it could be -- I've not tested it, but I reason that it is not done often enough that it would be a priority for optimizing now, unless someone else finds otherwise.