gtreshchev / RuntimeAudioImporter

Runtime Audio Importer plugin for Unreal Engine. Importing audio of various formats at runtime.
MIT License
336 stars 69 forks source link

Can't create audio, if import from another thread. #53

Closed Skino1337 closed 11 months ago

Skino1337 commented 1 year ago

My play func: image

If i directly call "play" function, sound play, but if i use call from timer, sounds just not play: image

My other code: image Audio imported successfuly, but audio from "CreateSound2D" is not valid.

gtreshchev commented 1 year ago

The timer doesn't execute the function from another thread but still from the same game thread. As for your issue with the sound wave not being played back when executed from the timer, it might be due to various reasons. For example, your object might be garbage collected during the import, and that's why the OnResultNative never gets broadcasted, not sure about your particular context.

gtreshchev commented 1 year ago

Accidentally closed the issue. So, if you have any other context, please let me know.

Skino1337 commented 1 year ago

Found solution, just this function in UE5 broken: image they return nullptr if WorldContextObject is World object.

Skino1337 commented 1 year ago

UWorld* World = GEngine->GetCurrentPlayWorld(nullptr); Also return null into ur delegete func.

gtreshchev commented 11 months ago

The OnResultNative delegate is executed in the game thread, so there should be no difference between executing your game logic-specific code and the code after OnResultNative in terms of their behavior, as all the delegates in the plugin broadcast the state externally to the game thread. So, I believe the issue is simply that the world of your UGothicUE5Dialog is invalid by the time you tried to obtain it. If you want, you could also directly pass the WorldContextObject in your UFUNCTION, which is especially relevant if you call it from a Blueprint class, as it almost always has a valid world in the majority of contexts:

UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"))
void Play(UObject* WorldContextObject);

Please feel free to reopen this issue if it's still relevant.