Giter Site home page Giter Site logo

Comments (2)

pokepetter avatar pokepetter commented on August 16, 2024

The recommended project structure is this:

    +---project
        \---resources
        |   \---select-long.wav
        +---main.py

By default ursina will load things from the root directory or a directory underneath.
It doesn't normally make sense to hard code paths to external resources.
The reason for just using names to load assets is so you can sort assets into
folders or make compressed versions without having to change the code.

If you really do need to change the root folder however, you can change application.asset_folder to the path you want.

I can't get it to error silently, but I'll look into making a more descriptive error message.

from ursina.

jgreenemi avatar jgreenemi commented on August 16, 2024

Thank you for the quick response! I lifted the main.py out of src and passing in os.path.join('resources', 'select-long') now loads and plays the audio file as expected. For a number of reasons I will continue to use my original project structure, and keep the bug open as os.path.join('..', 'resources', 'select-long') is a valid path that shouldn't be failing, regardless if it's uncommon to reference audio assets in this way.

I wasn't aware of the existence of "application.asset_folder", that is something I'll look into to better understand the canonical approach to loading audio files, and possibly other assets. Where can I find documentation describing its use, where it gets consumed, etc.?

The context around the reasoning for using names is helpful, I appreciate your sharing that! Can this be persisted somewhere in the code documentation? While the code explains the "how" of a decision it doesn't necessarily explain the "why". This benefit was not obvious to me as I didn't anticipate having to frequently change the format of existing resources, so much as changing their contents without changing the format (for example, it's more likely I'll change a wav to another wav with a different sound effect as opposed to changing a wav to ogg).

On the note about the error, are you saying you were unable to reproduce the error following the steps I provided? To be explicit, I want to know that a resource fails to load - but right now it appears to just print the fact that it failed to load, rather than actually throwing an exception. (The message could be more verbose about why it could not be loaded but that is beside the point.) I want to see an exception get thrown when a resource fails to load because this is an error state that needs to be handled. How a developer handles a resource loading failure in the code should be up to the developer, not swallowed by the library. Is this a behaviour from ShowBase, Ursina, or Panda3d?

from ursina.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.