Skip to content
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

AudioStreamOggVorbis C# needs Resource.Load not mentioned #10327

Open
a2937 opened this issue Nov 28, 2024 · 1 comment
Open

AudioStreamOggVorbis C# needs Resource.Load not mentioned #10327

a2937 opened this issue Nov 28, 2024 · 1 comment

Comments

@a2937
Copy link
Contributor

a2937 commented Nov 28, 2024

Your Godot version:

Godot 4.3

Issue description:

The documentation doesn't mention that load_from_buffer and load_from_file don't exist in the C# version of Godot. In order to load from a file, I have to use ResourceLoader.Load to load the audio files.

URL to the documentation page (if already existing):

https://docs.godotengine.org/en/stable/classes/class_audiostreamoggvorbis.html#class-audiostreamoggvorbis-method-load-from-file

@tetrapod00
Copy link
Contributor

They exist:

    /// <summary>
    /// <para>Creates a new AudioStreamOggVorbis instance from the given buffer. The buffer must contain Ogg Vorbis data.</para>
    /// </summary>
    public static AudioStreamOggVorbis LoadFromBuffer(byte[] buffer)
    {
        return (AudioStreamOggVorbis)NativeCalls.godot_icall_1_188(MethodBind0, buffer);
    }

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    private static readonly IntPtr MethodBind1 = ClassDB_get_method_with_compatibility(NativeName, MethodName.LoadFromFile, 797568536ul);

    /// <summary>
    /// <para>Creates a new AudioStreamOggVorbis instance from the given file path. The file must be in Ogg Vorbis format.</para>
    /// </summary>
    public static AudioStreamOggVorbis LoadFromFile(string path)
    {
        return (AudioStreamOggVorbis)NativeCalls.godot_icall_1_189(MethodBind1, path);
    }

Two things you might have missed:

  • C# methods and properties are generally in PascalCase rather than snake_case. The online class reference currently does not mention this directly or provide a C# version of each method directly, but in most cases you can mentally convert between the two casing conventions. The exceptions are listed here: https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_differences.html. There are vague plans to create a more dedicated C# class reference, because this really isn't ideal.
  • These are static functions, so you use them with the class itself rather than an instance of the class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants