Load assets from another project

I would like to create a resource like project that is included by other projects. My question is, how can I load models located in the resource project into other projects?
The reason for doing this is to have these resources used by multiple projects.

Are you talking about assetpacks?

Well It’s not just assets alone. Its a lot of code that is used in multiple places as well. Calling those are relatively easy as its just including and calling the method. I have assets used in the other projects in multiple places and thought it would be easy to add it to this middle/bridge project.

Code is easier. Just have your project depend on the other project.

Unfortunately, that doesn’t work for assets in that project and you will have to change the name of that project’s assets.jar (it’s configurable in project properties) and then add the jar specifically as a dependency of the main project.

Actually I have this working now.

This is all from memory as I’m not at home right now, if it doesn’t work I can check the exact settings on Saturday:

Just create a standard java jar library. Add code to it as you normally would, add assets from the root of the jar. i.e. textures would be in textures/tex1.png while code would be in com/example/test/test.java

You then go into the project settings under resources and set the resource root to /

Now you can load/modify etc assets as normal.

To use the project from another just add the library project to the libraries for the project that needs to use them. It will load both assets and code just fine.

@zarch said: Actually I have this working now.

This is all from memory as I’m not at home right now, if it doesn’t work I can check the exact settings on Saturday:

Just create a standard java jar library. Add code to it as you normally would, add assets from the root of the jar. i.e. textures would be in textures/tex1.png while code would be in com/example/test/test.java

You then go into the project settings under resources and set the resource root to /

Now you can load/modify etc assets as normal.

To use the project from another just add the library project to the libraries for the project that needs to use them. It will load both assets and code just fine.

Hmmm… when I did this then none of the SDK tools recognized the assets anymore.

Yep, that’s the thing I managed to fix with advice from normen. Your set up the asset route path inside the project settings and the SDK tools start working.

I can’t seem to get your solution working. If by resource root you mean assets folder? I tried to set that as / and it would try to bundle everything in C: into the jar.

Right, I’m home now so I could check my settings.

This is what my settings looks like on the library project:

You may need to restart the SDK after making the change, I can’t remember.

By doing that a “Project Assets” appears in the project explorer, you can access your assets there or inside Source Packages. Either way things like the SceneComposer etc all work fine.

To use the assets and/or code in the library project from another just add the project as a library to the one that needs to use it.

1 Like

Awesome, that worked. So simple and I never thought of trying it this way. Thanks!