Clean initial commit
This commit is contained in:
15
Source/ThisWillWork.Target.cs
Normal file
15
Source/ThisWillWork.Target.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ThisWillWorkTarget : TargetRules
|
||||
{
|
||||
public ThisWillWorkTarget(TargetInfo Target) : base(Target)
|
||||
{
|
||||
Type = TargetType.Game;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V6;
|
||||
|
||||
ExtraModuleNames.AddRange( new string[] { "ThisWillWork" } );
|
||||
}
|
||||
}
|
||||
61
Source/ThisWillWork/FindMyActorByName.cpp
Normal file
61
Source/ThisWillWork/FindMyActorByName.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "FindMyActorByName.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Engine/Blueprint.h"
|
||||
#include "UObject/ConstructorHelpers.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
// Sets default values
|
||||
AFindMyActorByName::AFindMyActorByName()
|
||||
{
|
||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void AFindMyActorByName::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void AFindMyActorByName::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
||||
UClass* AFindMyActorByName::GetBlueprintActorClassByName(const FString& BlueprintName, const FString& BlueprintPath)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("GetBlueprintActorClassByName called with name: %s"), *BlueprintName);
|
||||
|
||||
// Construct the full path to the Blueprint
|
||||
FString _BlueprintPath = FString::Printf(TEXT("%s%s.%s"), *BlueprintPath, *BlueprintName, *BlueprintName);
|
||||
UE_LOG(LogTemp, Warning, TEXT("Constructed Blueprint Path: %s"), *BlueprintPath);
|
||||
|
||||
// Load the Blueprint object
|
||||
UBlueprint* Blueprint = Cast<UBlueprint>(StaticLoadObject(UBlueprint::StaticClass(), nullptr, *_BlueprintPath));
|
||||
|
||||
if (Blueprint)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Blueprint found: %s"), *BlueprintName);
|
||||
if (Blueprint->GeneratedClass)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("GeneratedClass found for: %s"), *BlueprintName);
|
||||
return Blueprint->GeneratedClass; // Return the actor class
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("GeneratedClass not found for: %s"), *BlueprintName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("Blueprint not found at path: %s"), *BlueprintPath);
|
||||
}
|
||||
|
||||
return nullptr; // Return nullptr if the Blueprint is not found
|
||||
}
|
||||
27
Source/ThisWillWork/FindMyActorByName.h
Normal file
27
Source/ThisWillWork/FindMyActorByName.h
Normal file
@@ -0,0 +1,27 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "FindMyActorByName.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class THISWILLWORK_API AFindMyActorByName : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
AFindMyActorByName();
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Utilities") UClass* GetBlueprintActorClassByName(const FString& BlueprintName, const FString& BlueprintPath);
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
};
|
||||
27
Source/ThisWillWork/MyActor.cpp
Normal file
27
Source/ThisWillWork/MyActor.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "MyActor.h"
|
||||
|
||||
// Sets default values
|
||||
AMyActor::AMyActor()
|
||||
{
|
||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void AMyActor::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void AMyActor::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
||||
26
Source/ThisWillWork/MyActor.h
Normal file
26
Source/ThisWillWork/MyActor.h
Normal file
@@ -0,0 +1,26 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "MyActor.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class THISWILLWORK_API AMyActor : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
AMyActor();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
};
|
||||
22
Source/ThisWillWork/MyCustomActorFinder.cpp
Normal file
22
Source/ThisWillWork/MyCustomActorFinder.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "MyCustomActorFinder.h"
|
||||
#include "Engine/World.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "EngineUtils.h"
|
||||
|
||||
AActor* MyCustomActorFinder::FindActorByName(const FString& ActorName)
|
||||
{
|
||||
for (TActorIterator<AActor> It(GetWorld()); It; ++It)
|
||||
{
|
||||
AActor* Actor = *It;
|
||||
if (Actor->GetName() == ActorName)
|
||||
{
|
||||
return Actor;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
16
Source/ThisWillWork/MyCustomActorFinder.h
Normal file
16
Source/ThisWillWork/MyCustomActorFinder.h
Normal file
@@ -0,0 +1,16 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "MyCustomActorFinder.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class GAMEIDEAV5_5_API AMyCustomActorFinder : public AActor
|
||||
{
|
||||
|
||||
GENERATED_BODY()
|
||||
public: UFUNCTION(BlueprintCallable, Category = "Utilities") AActor* FindActorByName(const FString& ActorName);
|
||||
};
|
||||
|
||||
23
Source/ThisWillWork/ThisWillWork.Build.cs
Normal file
23
Source/ThisWillWork/ThisWillWork.Build.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class ThisWillWork : ModuleRules
|
||||
{
|
||||
public ThisWillWork(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { });
|
||||
|
||||
// Uncomment if you are using Slate UI
|
||||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
|
||||
// Uncomment if you are using online features
|
||||
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
|
||||
|
||||
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
|
||||
}
|
||||
}
|
||||
6
Source/ThisWillWork/ThisWillWork.cpp
Normal file
6
Source/ThisWillWork/ThisWillWork.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "ThisWillWork.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, ThisWillWork, "ThisWillWork" );
|
||||
6
Source/ThisWillWork/ThisWillWork.h
Normal file
6
Source/ThisWillWork/ThisWillWork.h
Normal file
@@ -0,0 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
15
Source/ThisWillWorkEditor.Target.cs
Normal file
15
Source/ThisWillWorkEditor.Target.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ThisWillWorkEditorTarget : TargetRules
|
||||
{
|
||||
public ThisWillWorkEditorTarget(TargetInfo Target) : base(Target)
|
||||
{
|
||||
Type = TargetType.Editor;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V6;
|
||||
|
||||
ExtraModuleNames.AddRange( new string[] { "ThisWillWork" } );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user