Comments (2)
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.
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)
- Loading issue for settings.py HOT 3
- Using more than one boxcast in a single update breaks some of the boxcasts. HOT 2
- Feature - allow the Audio class to allow .mp3 files. HOT 1
- Remove all entities HOT 1
- RTL language support (Persian/Farsi)
- Can't use pyinstaller to ursina HOT 4
- how to load multi textures for one model HOT 1
- Cannot build to exe because of module not found error HOT 2
- how to optimize gaem
- FirstPersonController sees through entities because of shaders HOT 2
- turn string to Vec3
- Cyrillic print in ingame console.
- Setting mouse.visible = False in borderless mode causes client window to snap back to original location HOT 1
- Operation of color.rgb() HOT 2
- Some Errors in the documentation
- Issues with cursor scale on Mac
- Issues with unit tests HOT 1
- How to detect the top and bottom of an entity HOT 2
- stable branch?
- Issue with 2d platformer controller HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ursina.