Announcement

Collapse
No announcement yet.

Adding Custom C++ BP Function Not Working as Expected

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Adding Custom C++ BP Function Not Working as Expected

    Hey,

    I'm pretty new to C++ so I apologize that this is probably extremely basic. I come from entirely Blueprint programming. I'm trying to add a custom blueprint function that gives me an array of the names of available audio output devices in Windows. But when I add the blueprint function to use it, I get the attached error. I need this function to work in any blueprint class, there is no AudioDeviceOutput class, just the function I'm making.

    Here is my code.

    header

    Code:
    #pragma once
    
    #include "CoreMinimal.h"
    #include "Kismet/BlueprintFunctionLibrary.h"
    #include "XAudio2Device.h"
    #include "AudioDeviceOutput.generated.h"
    
    
    /**
     * 
     */
    UCLASS()
    class MYGAME_API UAudioDeviceOutput : public UBlueprintFunctionLibrary
    {
        GENERATED_BODY() public:
    
            UFUNCTION(BlueprintPure, Category = "Custom", meta = (Keywords = "GetAudioOutputDevices"))
                TArray<FString> GetAudioDevices();
    };
    cpp

    Code:
    #include "AudioDeviceOutput.h"
    
    TArray<FString> UAudioDeviceOutput::GetAudioDevices()
    {
        FAudioDevice* AudioDevice = GEngine->GetMainAudioDevice();
        TArray<FString> AudioDeviceList;
        AudioDevice->GetAudioDeviceList(AudioDeviceList);
        return AudioDeviceList;
    }

    #2
    Try this:

    Code:
        UFUNCTION(BlueprintPure, Category = "Custom", meta = (Keywords = "GetAudioOutputDevices")) 
         static TArray<FString> GetAudioDevices()
    | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

    Comment

    Working...
    X