javalibgdx3d-modelasset-management

LIbgdx - Why is AssetManager not working?


I have tried to use Asset Manager to load some assets. Everything works fine, except for one part. Here is my code

My AssetHandler Class (contains assetManager)

public class AssetHandler {
    public static AssetManager manager;

    public static String wallFile = "3d/wall.g3db";
    public static String floorFile = "3d/floor.g3db";
    public static String stairsFile = "3d/stairs.g3db";
    public static String characterFile = "3d/character.g3db";

    public static void load() {
        manager = new AssetManager();

        manager.load(wallFile, Model.class);
        manager.load(floorFile, Model.class);
        manager.load(stairsFile, Model.class);
        manager.load(characterFile, Model.class);

    }

    public static void dispose() {
        manager.clear();
        manager.dispose();
    }

    public static void dispose(String fileName) {
        manager.unload(fileName);
    }

}

when I attempt to use the file, I wrote:

 model = AssetHandler.manager.get(AssetHandler.characterFile, Model.class);
 model = AssetHandler.manager.get(AssetHandler.wallFile, Model.class);

everything works but character file doesn't Other files do, but just this one file don't

Please Help I don't get why No errors/ exceptions poped up


Solution

  • Solution:

    Add

    manager.finishLoading();
    

    at the end of load method.


    If you want to do it asynchronously, you should use manager.update() in render loop.

    Refer to this for more information.


    Try to avoid public fields and static methods. (Not related to the question).