-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose load/import methods for use with file from user directory #17748
Comments
You could try to import the audio file under |
Those files are generated at runtime so i don't think it is possible to import it that way (I'm new to godot so correct me if I'm wrong). But could it be possible to manually generate import files? |
Ok, think that this is impossible now. The .import files are generated from the Godot Editor while tragging a file into the project directory, e. g. https://github.com/godotengine/godot-demo-projects/blob/master/2d/physics_platformer/music.ogg.import |
Tell me if I understand correctly. Importing and resource generation is implemented as part of editor functionality and not game engine so it cannot be done at the runtime? |
In v3 you can't use any resource without first importing them (a process that loosy re-compresses the asset and put's it in the .import folder by default/recommended procedure) by design and from what I've seen the authors won't implement the direct access to assets as was the norm in v2 and requested multiple times here for no good reason they could give other than the ease of use by users (the developers needs don't matter) ... In addition they are ignoring major bugs in the import system and not even notifying the users of them - for example: godotengine/godot-docs#1256 & #17726 Let's see how long are they going to take to fix or notify the developers about that "little" bug. And don't get me started on some other "features" they don't intend to even consider implementing alternatives of like this one here ... |
Is it possible to initialize the import procedure at runtime via GDNative so the generated This could solve #14954 because it won't be necessary anymore to package videos which makes the |
What you are trying to import isn't a resource that godot recognizes. Resources for godot are files that have been imported via any of the import mechanism there are and have extra information and metadata that the original file doesn't have. For example, a imported .png will not only import it with whatever import options you give it but it will be automatically compressed and prepared for the different compress formats you select in the project settings. It doesn't modify the original .png file. If you need to load a external file a successful loading will depend on what the file is but you will have to do it manually. The old 2.x import system wouldn't let you load it either. You can load an external ogg file like: func load_ogg(file):
var path = "Z:\\godot_projects\\%s.ogg" % file
var ogg_file = File.new()
ogg_file.open(path, File.READ)
var bytes = ogg_file.get_buffer(ogg_file.get_len())
var stream = AudioStreamOGGVorbis.new()
stream.data = bytes
$AudioStreamPlayer.stream = stream
ogg_file.close()
|
This is really helpful piece of code |
You should definitely double check you're comment because right now I can't use PNG files without importing them, and when I do using "Compress Lossless (PNG)" method the result is a Loosy compressed PNG file with data and quality lost during the import process (described with proof in 17726) ... P.S. The decision to add extra data to each asset instead of using the obligatory extra files generated by the import process was probably the second biggest mistake in the new version right after changing the video engine without fallback method - they both need one and so far only one is getting such. |
@bartosz-m Is this issue solved now? Maybe it's better to change the title to make clear if it's a feature request (@hubslave 's comment) |
I've been able to overcome my problem and it looks like the main issue was different than that in the title I wrote. Problem was missing documentation for |
@LinuxUserGD The code provided by @mrcdk is just a solution for a part of the problem the author's are not willing to fix and labeling as "feature" and not a missing documentation problem - this will not be listed there unless the Godot engine policy changes. I'll not be surprised if this solution stops working in a future version and the reason is code labeled as bugfix ... |
@hubslave There isn't just one solution for all assets, e. g. a video can't be compressed like a png but needs much space in the exported .pck #14954 And @mrcdk (contributor) fixed @bartosz-m problem two hours after your comment (--> documentation issue) Image artifacts (#17726) should be an engine's issue. And dynamically importing assets (media/ meshes) is a feature request, because Godot doesn't support it yet (--> Waiting for Godot) Conclusion: Better close this issue and create seperate ones |
Before closing this issue I would like to ask where create new one about missing documentation: here or on godot-docs? |
godot-docs (not engine code specific) |
As advised I'm closing this issue |
Godot version:
3.0.2
Issue description:
I was trying to import audio "resources" from user directory using
user://
but I could find how to do that from gdscript.load
functions generates error for ogg,wav,opusI can successfully load file content as a
PoolByteArray
but I wasn't able to find a way to create from it usable resource.I'm guessing that there are method that could import those file as resource at runtime, but are living in c++, so maybe they could get bindings for the gdscript side?
Steps to reproduce:
var user_sample = load("user://sample.ogg")
The text was updated successfully, but these errors were encountered: