UActorComponent
派生自UObject
。
它是所有“組件”的基類。
只有AActor
以及其派生類纔能有“組件”。
聲明
UCLASS ( DefaultToInstanced, BlueprintType, abstract, meta= ( ShortTooltip= "An ActorComponent is a reusable component that can be added to any actor." ) , config= Engine)
class ENGINE_API UActorComponent : public UObject, public IInterface_AssetUserData
{
GENERATED_BODY ( )
. . .
}
生命週期
virtual void TickComponent ( float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction * ThisTickFunction) ;
virtual void BeginPlay ( ) ;
virtual void EndPlay ( const EEndPlayReason:: Type EndPlayReason) ;
virtual void OnRegister ( ) ;
virtual void OnUnregister ( ) ;
關於Tick
virtual void TickComponent ( float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction * ThisTickFunction) ;
UFUNCTION ( BlueprintCallable, Category= "Utilities" )
virtual void SetComponentTickEnabled ( bool bEnabled) ;
UFUNCTION ( BlueprintCallable, Category= "Utilities" )
virtual bool IsComponentTickEnabled ( ) const ;
關於Tag
UPROPERTY ( EditAnywhere, BlueprintReadWrite, Category= Tags)
TArray< FName> ComponentTags;
UFUNCTION ( BlueprintCallable, Category= "Components" )
bool ComponentHasTag ( FName Tag) const ;
關於Activate
UFUNCTION ( BlueprintCallable, Category= "Components|Activation" , meta= ( UnsafeDuringActorConstruction= "true" ) )
virtual void Activate ( bool bReset= false ) ;
UFUNCTION ( BlueprintCallable, Category= "Components|Activation" , meta= ( UnsafeDuringActorConstruction= "true" ) )
virtual void Deactivate ( ) ;
UFUNCTION ( BlueprintCallable, Category= "Components|Activation" , meta= ( UnsafeDuringActorConstruction= "true" ) )
virtual void SetActive ( bool bNewActive, bool bReset= false ) ;
UFUNCTION ( BlueprintCallable, Category= "Components|Activation" , meta= ( UnsafeDuringActorConstruction= "true" ) )
bool IsActive ( ) const { return bIsActive; }