UE5--012--MusicManager


1. MusicManager

1.1 MusicManager.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MusicManager.generated.h"

UCLASS()
class C005DODGEBALL_API AMusicManager : public AActor
{
    GENERATED_BODY()
    
public:    
    // Sets default values for this actor's properties
    AMusicManager();

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

public:    
    // Called every frame
    virtual void Tick(float DeltaTime) override;

protected:
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
    class UAudioComponent* AudioComponent;


};


1.2MusicManager.cpp

#include "MusicManager.h"
#include "Components/AudioComponent.h"


// Sets default values
AMusicManager::AMusicManager()
{
     // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = false;

    AudioComponent = CreateDefaultSubobject<UAudioComponent>(TEXT("MusicComponent"));

}

// Called when the game starts or when spawned
void AMusicManager::BeginPlay()
{
    Super::BeginPlay();
    
}

// Called every frame
void AMusicManager::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

}


1.3 BP_MusicManager

image

posted @ 2025-04-05 18:50  ParamousGIS  阅读(23)  评论(0)    收藏  举报