예제 #1
0
FGridWidget::FGridWidget()
{
	LevelGridMaterial = (UMaterial*)StaticLoadObject( UMaterial::StaticClass(),NULL,TEXT("/Engine/EditorMaterials/LevelGridMaterial.LevelGridMaterial"),NULL,LOAD_None,NULL );
	LevelGridMaterialInst = UMaterialInstanceDynamic::Create(LevelGridMaterial, NULL);

	LevelGridMaterial2 = (UMaterial*)StaticLoadObject( UMaterial::StaticClass(),NULL,TEXT("/Engine/EditorMaterials/LevelGridMaterial2.LevelGridMaterial2"),NULL,LOAD_None,NULL );
	LevelGridMaterialInst2 = UMaterialInstanceDynamic::Create(LevelGridMaterial2, NULL);
}
예제 #2
0
AActor * AMapCreator::createMap(bool binary, ACameraActor * camera, AStaticMeshActor * floor)
{
	binMap = binary;

	// Read Character start position
	getPositions();

	// Adjust gridSize and meshSize different depending on if binary or not
	float ratio = gridSize / meshSide;

	// Set floor size depending on map and cell to view dimensions
	height = getMap().Num();
	width = getMap()[0].Num();

	floor->SetActorScale3D(FVector(height * ratio, width * ratio, 1));
	floor->SetActorLocation(FVector((width / 2) * gridSize, (height / 2) * gridSize, -((meshSide / 2) + characterHeight)));

	// Center camera above the center of floor, at a distance that fits the entire field
	float FOV = 90;
	float cameraHeight = width / tan(FOV / 2);
	camera->SetActorLocation(floor->GetActorLocation() + FVector(0, 0, height * gridSize));

	// Get MazeBlock blueprint
	auto cls = StaticLoadObject(UObject::StaticClass(), nullptr,
								TEXT("Blueprint'/Game/Blueprints/MazeBlock.MazeBlock'"));
	UBlueprint * bp = Cast<UBlueprint>(cls);
	blockBP = (UClass*)bp->GeneratedClass;

	// Get MazeBlock2 blueprint
	cls = StaticLoadObject(UObject::StaticClass(), nullptr,
		TEXT("Blueprint'/Game/Blueprints/MazeBlock2.MazeBlock2'"));
	bp = Cast<UBlueprint>(cls);
	blockBP2 = (UClass*)bp->GeneratedClass;

	// Get Character blueprint
	cls = StaticLoadObject(UObject::StaticClass(), nullptr,
						   TEXT("Blueprint'/Game/Blueprints/Character.Character'"));
	bp = Cast<UBlueprint>(cls);
	TSubclassOf<class UObject> characterBP = (UClass*)bp->GeneratedClass;

	// Spawn objects
	FVector location = spawnMap(GWorld->GetWorld());

	//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red,
	//								 FString::Printf(TEXT("{%f.2, %f.2, %f.2}"),
	//												 location.X, location.Y, location.Z));
	return GWorld->GetWorld()->SpawnActor<AActor>(characterBP, location, { 0,0,0 });
}
예제 #3
0
// Sets default values
ABullet::ABullet(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
 	// 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;

	bulletCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("Bullet Collider"));
	// default bullet size as a safety measure
	bulletCollider->InitSphereRadius(0.5f);
	//bulletCollider->SetSimulatePhysics(true);   // THIS WAS A GOD DAMN TRAP FOR PROJECTILE MOVEMENT
	bulletCollider->SetNotifyRigidBodyCollision(true);
	bulletCollider->BodyInstance.SetCollisionProfileName("Bullet");
	// bulletCollider->BodyInstance.SetMassScale(0.01f);
	// NOTE: Would like to simulate SOME gravity in the future
	//bulletCollider->SetEnableGravity(false);
	bulletCollider->OnComponentHit.AddDynamic(this, &ABullet::OnHit);
	RootComponent = bulletCollider;

	// set up visual component
	myFlipbook = ObjectInitializer.CreateDefaultSubobject<UPaperFlipbookComponent>(this, TEXT("AnimComponent"));
	myFlipbook->AttachTo(RootComponent);
	UPaperFlipbook* bulletFlip = Cast<UPaperFlipbook>(StaticLoadObject(UPaperFlipbook::StaticClass(), NULL, TEXT("PaperFlipbook'/Game/Art/Sprites/MH_Bullet_Flipbook.MH_Bullet_Flipbook'")));
	myFlipbook->SetFlipbook(bulletFlip);

	bulletMovement = ObjectInitializer.CreateDefaultSubobject<UProjectileMovementComponent>(this, TEXT("Bullet Movement"));
	bulletMovement->InitialSpeed = 120.0f;
	bulletMovement->UpdatedComponent = bulletCollider;
	bulletMovement->bRotationFollowsVelocity = true;
	bulletMovement->bShouldBounce = true;
	bulletMovement->Bounciness = 0.3f;

	// Bullet max lifespan, in case it flies into the sky or something
	InitialLifeSpan = 15.0f;

}
void UVaRest_BreakJson::CreateProjectionPins(UEdGraphPin *Source)
{
	const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
	UClass *Class = Cast<UClass>(StaticLoadObject(UClass::StaticClass(), NULL, TEXT("class'VaRestPlugin.VaRestJsonObject'")));
	for (TArray<FVaRest_NamedType>::TIterator it(Outputs); it; ++it)
	{
		FString Type;
		UObject *Subtype = nullptr;
		FString FieldName = (*it).Name;
		switch ((*it).Type) {
		case EVaRest_JsonType::JSON_Bool:
			Type = K2Schema->PC_Boolean;
			break;
		case EVaRest_JsonType::JSON_Number:
			Type = K2Schema->PC_Float;
			break;
		case EVaRest_JsonType::JSON_String:
			Type = K2Schema->PC_String;
			break;
		case EVaRest_JsonType::JSON_Object:
			Type = K2Schema->PC_Object;
			Subtype = Class;
			break;
		}
		UEdGraphPin *OutputPin = CreatePin(EGPD_Output, Type, TEXT(""), Subtype, (*it).bIsArray, false, (*it).Name);
	}
}
void UAREquipmentComponent::ChangeLegItem(FName ItemName)
{
	//this can be called by both client and server
	//server need to do it, to propagate mesh change
	//to other players.
	//and client
	UARItemDataAsset* ItemDataAsset = Cast<UARItemDataAsset>(StaticLoadObject(UARItemDataAsset::StaticClass(), NULL, *LegItemDataAssetPath, NULL, LOAD_None, NULL));

	if (ItemDataAsset && ItemDataAsset->Items.Num() > 0)
	{
		TArray<FStringAssetReference> ObjToLoad;
		FStreamableManager& Loader = UARSingleton::Get().AssetLoader;

		//do it this way until I figure out predicate...
		for (FARItemInfo& item : ItemDataAsset->Items)
		{
			if (item.ItemName == ItemName)
			{
				LegMeshToLoad = item.ItemMesh.ToStringReference();
				ObjToLoad.AddUnique(LegMeshToLoad);
				Loader.RequestAsyncLoad(ObjToLoad, FStreamableDelegate::CreateUObject(this, &UAREquipmentComponent::DoAsyncChestChange));
				//ChestItem = item.ItemName;
				return;
			}
		}
	}

	//this is only for server
	//because here we will be changing character stats
	if (GetOwnerRole() == ROLE_Authority)
	{

	}
	//return false;
}
예제 #6
0
void AWorldSettings::PreInitializeComponents()
{
	Super::PreInitializeComponents();

	// create the emitter pool
	// we only need to do this for the persistent level's WorldSettings as sublevel actors will have their WorldSettings set to it on association
	if (GetNetMode() != NM_DedicatedServer && IsInPersistentLevel())
	{
		UWorld* World = GetWorld();
		check(World);		

		// only create once - 
		if (World->MyParticleEventManager == NULL && !GEngine->ParticleEventManagerClassPath.IsEmpty())
		{
			TSubclassOf<AParticleEventManager> ParticleEventManagerClass = Cast<UClass>(StaticLoadObject(UClass::StaticClass(), NULL, *GEngine->ParticleEventManagerClassPath, NULL, LOAD_NoWarn, NULL));
			if (ParticleEventManagerClass != NULL)
			{
				FActorSpawnParameters SpawnParameters;
				SpawnParameters.Owner = this;
				SpawnParameters.Instigator = Instigator;
				World->MyParticleEventManager = World->SpawnActor<AParticleEventManager>(ParticleEventManagerClass, SpawnParameters );
			}
		}
	}
}
예제 #7
0
UObject* FSlateSound::GetResourceObject( ) const
{
	// We might still be holding a legacy resource name, in which case we need to test that first and load it if required
	if (LegacyResourceName_DEPRECATED != NAME_None)
	{
		// Do we still have a valid reference in our weak-ptr?
		UObject* LegacyResourceObject = LegacyResourceObject_DEPRECATED.Get();

		if (!LegacyResourceObject)
		{
			// We can't check the object type against USoundBase as we don't have access to it here
			// The user is required to cast the result of FSlateSound::GetResourceObject so we should be fine
			LegacyResourceObject = StaticFindObject(UObject::StaticClass(), nullptr, *LegacyResourceName_DEPRECATED.ToString());
			if (!ResourceObject)
			{
				LegacyResourceObject = StaticLoadObject(UObject::StaticClass(), nullptr, *LegacyResourceName_DEPRECATED.ToString());
			}

			// Cache this in the weak-ptr to try and avoid having to load it all the time
			LegacyResourceObject_DEPRECATED = LegacyResourceObject;
		}

		return LegacyResourceObject;
	}

	return ResourceObject;
}
	/**
	 * Simulates the user pressing the blueprint's compile button (will load the
	 * blueprint first if it isn't already).
	 * 
	 * @param  BlueprintAssetPath	The asset object path that you wish to compile.
	 * @return False if we failed to load the blueprint, true otherwise
	 */
	static bool CompileBlueprint(const FString& BlueprintAssetPath)
	{
		UBlueprint* BlueprintObj = Cast<UBlueprint>(StaticLoadObject(UBlueprint::StaticClass(), NULL, *BlueprintAssetPath));
		if (!BlueprintObj || !BlueprintObj->ParentClass)
		{
			UE_LOG(LogBlueprintAutomationTests, Error, TEXT("Failed to compile invalid blueprint, or blueprint parent no longer exists."));
			return false;
		}

		UPackage* const BlueprintPackage = Cast<UPackage>(BlueprintObj->GetOutermost());
		// compiling the blueprint will inherently dirty the package, but if there 
		// weren't any changes to save before, there shouldn't be after
		bool const bStartedWithUnsavedChanges = (BlueprintPackage != nullptr) ? BlueprintPackage->IsDirty() : true;

		bool bIsRegeneratingOnLoad = false;
		bool bSkipGarbageCollection = true;
		FBlueprintEditorUtils::RefreshAllNodes(BlueprintObj);
		FKismetEditorUtilities::CompileBlueprint(BlueprintObj, bIsRegeneratingOnLoad, bSkipGarbageCollection);

		if (BlueprintPackage != nullptr)
		{
			BlueprintPackage->SetDirtyFlag(bStartedWithUnsavedChanges);
		}

		return true;
	}
void FGameplayDebuggerCategory_AI::DrawPawnIcons(UWorld* World, AActor* DebugActor, APawn* SkipPawn, FGameplayDebuggerCanvasContext& CanvasContext)
{
	FString FailsafeIcon = TEXT("/Engine/EngineResources/AICON-Green.AICON-Green");
	for (FConstPawnIterator It = World->GetPawnIterator(); It; ++It)
	{
		const APawn* ItPawn = *It;
		if (IsValid(ItPawn) && SkipPawn != ItPawn)
		{
			const FVector IconLocation = ItPawn->GetActorLocation() + FVector(0, 0, ItPawn->GetSimpleCollisionHalfHeight());
			const AAIController* ItAI = Cast<const AAIController>(ItPawn->GetController());

			FString DebugIconPath = IsValid(ItAI) ? ItAI->GetDebugIcon() : FailsafeIcon;
			if (CanvasContext.IsLocationVisible(IconLocation) && DebugIconPath.Len())
			{
				UTexture2D* IconTexture = (UTexture2D*)StaticLoadObject(UTexture2D::StaticClass(), NULL, *DebugIconPath, NULL, LOAD_NoWarn | LOAD_Quiet, NULL);
				FCanvasIcon CanvasIcon = UCanvas::MakeIcon(IconTexture);
				if (CanvasIcon.Texture)
				{
					const FVector2D ScreenLoc = CanvasContext.ProjectLocation(IconLocation);
					const float IconSize = (DebugActor == ItPawn) ? 32.0f : 16.0f;

					CanvasContext.DrawIcon(FColor::White, CanvasIcon, ScreenLoc.X, ScreenLoc.Y - IconSize, IconSize / CanvasIcon.Texture->GetSurfaceWidth());
				}
			}
		}
	}
}
void AGameplayDebuggingHUDComponent::DrawOverHeadInformation(APlayerController* PC, class UGameplayDebuggingComponent *DebugComponent)
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	APawn* MyPawn = Cast<APawn>(DebugComponent->GetSelectedActor());
	const FVector Loc3d = MyPawn ? MyPawn->GetActorLocation() + FVector(0.f, 0.f, MyPawn->GetSimpleCollisionHalfHeight()) : FVector::ZeroVector;

	if (OverHeadContext.Canvas->SceneView == NULL || OverHeadContext.Canvas->SceneView->ViewFrustum.IntersectBox(Loc3d, FVector::ZeroVector) == false)
	{
		return;
	}

	const FVector ScreenLoc = OverHeadContext.Canvas->Project(Loc3d);
	static const FVector2D FontScale(1.f, 1.f);
	UFont* Font = GEngine->GetSmallFont();

	float TextXL = 0.f;
	float YL = 0.f;
	FString ObjectName = FString::Printf( TEXT("{yellow}%s {white}(%s)"), *DebugComponent->ControllerName, *DebugComponent->PawnName);
	CalulateStringSize(OverHeadContext, OverHeadContext.Font, ObjectName, TextXL, YL);

	bool bDrawFullOverHead = MyPawn != nullptr && GetDebuggingReplicator()->GetSelectedActorToDebug() == MyPawn;
	float IconXLocation = OverHeadContext.DefaultX;
	float IconYLocation = OverHeadContext.DefaultY;
	if (bDrawFullOverHead)
	{
		OverHeadContext.DefaultX -= (0.5f*TextXL*FontScale.X);
		OverHeadContext.DefaultY -= (1.2f*YL*FontScale.Y);
		IconYLocation = OverHeadContext.DefaultY;
		OverHeadContext.CursorX = OverHeadContext.DefaultX;
		OverHeadContext.CursorY = OverHeadContext.DefaultY;
	}

	if (DebugComponent->DebugIcon.Len() > 0)
	{
		UTexture2D* RegularIcon = (UTexture2D*)StaticLoadObject(UTexture2D::StaticClass(), NULL, *DebugComponent->DebugIcon, NULL, LOAD_NoWarn | LOAD_Quiet, NULL);
		if (RegularIcon)
		{
			FCanvasIcon Icon = UCanvas::MakeIcon(RegularIcon);
			if (Icon.Texture)
			{
				const float DesiredIconSize = bDrawFullOverHead ? 32.f : 16.f;
				DrawIcon(OverHeadContext, FColor::White, Icon, IconXLocation, IconYLocation - DesiredIconSize, DesiredIconSize / Icon.Texture->GetSurfaceWidth());
			}
		}
	}

	if (bDrawFullOverHead)
	{
		OverHeadContext.FontRenderInfo.bEnableShadow = bDrawFullOverHead;
		PrintString(OverHeadContext, bDrawFullOverHead ? FColor::White : FColor(255, 255, 255, 128), FString::Printf(TEXT("%s\n"), *ObjectName));
		OverHeadContext.FontRenderInfo.bEnableShadow = false;
	}

	if (EngineShowFlags.DebugAI)
	{
		DrawPath(PC, DebugComponent);
	}
#endif //!(UE_BUILD_SHIPPING || UE_BUILD_TEST)
}
void UVaRest_BreakJson::AllocateDefaultPins()
{
	const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
	UClass *Class = Cast<UClass>(StaticLoadObject(UClass::StaticClass(), NULL, TEXT("class'VaRestPlugin.VaRestJsonObject'")));
	UEdGraphPin* Pin = CreatePin(EGPD_Input, K2Schema->PC_Object, TEXT(""), Class, false, false, TEXT("Target"));
	K2Schema->SetPinDefaultValueBasedOnType(Pin);
	CreateProjectionPins(Pin);
}
예제 #12
0
/** Constructor */
FEdModeLevel::FEdModeLevel() 
	: FEdMode()
	, SelectedLevel( NULL )
{
	UMaterial* GizmoMaterial = (UMaterial*)StaticLoadObject( UMaterial::StaticClass(),NULL,TEXT("/Engine/EditorMaterials/LevelTransformMaterial.LevelTransformMaterial") );
	BoxMaterial = UMaterialInstanceDynamic::Create( GizmoMaterial, NULL );

	bIsTracking = false;
}
예제 #13
0
void UEImageFile::createSprite()
{
	texture = Cast<UTexture2D>(StaticLoadObject(UTexture2D::StaticClass(), NULL, *FPaths::Combine(*imagePath, ANSI_TO_TCHAR(path().c_str()))));
	if (texture != NULL)
	{
		width = texture->GetSizeX();
		height = texture->GetSizeY();
	}
}
void FAnimNode_MMDIK::InitializeBoneReferences(const FBoneContainer& RequiredBones)
{
	const FStringAssetReference& AssetRef = MMDExtendAssetRef.ToStringReference();

	UE_LOG(LogAnimation, Warning, TEXT("FAnimNode_MMDIK::InitializeBoneReferences: AssetRef[%s]."), *AssetRef.ToString());

	MMDExtendAssetRef = Cast<UMMDExtendAsset>(StaticLoadObject(UMMDExtendAsset::StaticClass(), NULL, *AssetRef.ToString()));

}
예제 #15
0
ASensor::ASensor()
{
 	// 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;
	/* Check if instantiation is real or just for placement guidlines */
	if (UObject::IsTemplate(RF_Transient)){
		return;
	}

//	UObject* something = StaticLoadObject(UObject::StaticClass(), NULL, TEXT("Blueprint'/Game/SensorNode.SensorNode'"));
//	UBlueprint* bp = Cast<UBlueprint>(something);
//	TSubclassOf<class UObject> MyItemBlueprint;
//	MyItemBlueprint = (UClass*)bp->GeneratedClass;
//	TSubclassOf<class UObject> MyItemBlueprint;
//	MyItemBlueprint = Cast<UClass>(blueprint->GeneratedClass);

	/* Find the blueprint of the 3D model */
	UBlueprint* blueprint = Cast<UBlueprint>(StaticLoadObject(UObject::StaticClass(), NULL, TEXT("Blueprint'/Game/SensorNode.SensorNode'")));
	TSubclassOf<class UObject> MyItemBlueprint = (UClass*)(blueprint->GeneratedClass);
	if (MyItemBlueprint != NULL) {
		UE_LOG(LogNet, Log, TEXT("BName: %s %s"), *(MyItemBlueprint->GetClass()->GetName()), *(this->GetActorLocation().ToString()));
	} else {
		UE_LOG(LogNet, Log, TEXT("I got nothing"));
	}

	/* Spawn the 3D model for the sensor in the virtual world */
	SensorActor = SpawnBP<AActor>(GetWorld(), MyItemBlueprint, this->GetActorLocation(), this->GetActorRotation());
	if(SensorActor) {
		UE_LOG(LogNet, Log, TEXT("SeName: %s"), *(SensorActor->GetName()));
		this->Children.Add(SensorActor);
		SensorActor->SetOwner(this);
		UE_LOG(LogNet, Log, TEXT("New Sensor: %s"), *(SensorActor->GetName()))
		/* Retrieve all the LEDS and turn them OFF */
		SensorActor->GetComponents(Leds);
		for (USpotLightComponent *l: Leds) {
			if (l == NULL) continue;
			UE_LOG(LogNet, Log, TEXT("%s owned by %s"), *(l->GetName()),
					*(l->GetOwner()->GetName()));
			l->SetIntensity(LEDOFF);
		}
	}
	else {
		UE_LOG(LogNet, Log, TEXT("SeName:Not spawned!"));
	}
//	AVirtual_CPS_WorldGameMode* gm = ((AVirtual_CPS_WorldGameMode*)GetWorld()->GetAuthGameMode());
//	if (gm)	ID = ((AVirtual_CPS_WorldGameMode*)GetWorld()->GetAuthGameMode())->getNewSensorID();

	/* Networking setup */
	sockSubSystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
	socket = sockSubSystem->CreateSocket(NAME_DGram, TEXT("UDPCONN2"), true);
	if (socket) UE_LOG(LogNet, Log, TEXT("Created Socket"));
	socket->SetReceiveBufferSize(RecvSize, RecvSize);
	socket->SetSendBufferSize(SendSize, SendSize);


}
	// Create a shape mesh actor from a given asset name
	AStaticMeshActor* CreateShapeMeshActor( const FString ShapeAssetName, FVector Location )
	{
		UStaticMesh* StaticMeshAsset = (UStaticMesh*)StaticLoadObject(UStaticMesh::StaticClass(), nullptr, *ShapeAssetName, nullptr, LOAD_None, nullptr);
		TestBase->TestNotNull<UStaticMesh>(FString::Printf(TEXT("Failed to find mesh object %s."), *ShapeAssetName), StaticMeshAsset);

		AStaticMeshActor* ShapeMeshActor = Cast<AStaticMeshActor>(FActorFactoryAssetProxy::AddActorForAsset(StaticMeshAsset));
		ShapeMeshActor->SetActorLocation(Location);
		TestBase->TestNotNull<AActor>(FString::Printf(TEXT("Failed to create MeshActor for %s."), *ShapeAssetName), ShapeMeshActor); 
		return ShapeMeshActor;
	}
예제 #17
0
/**
* Loads the animation from a given track keyframe
* @param Track The keyframe to load the animation from
* @param Owner The owner of the potentially loaded animation data
* @returns The loaded animation, else nullptr if not found or unset
*/
UFaceFXAnim* GetAnimation(const FFaceFXTrackKey& Track, UObject* Owner)
{
	UFaceFXAnim* NewAnim = Track.Animation.Get();
	if(!NewAnim && Track.Animation.ToStringReference().IsValid())
	{
		NewAnim = Cast<UFaceFXAnim>(StaticLoadObject(UFaceFXAnim::StaticClass(), Owner, *Track.Animation.ToStringReference().ToString()));
	}

	return NewAnim;
}
bool FBlueprintReparentTest::RunTest(const FString& BlueprintAssetPath)
{
	bool bTestFailed = false;

	UBlueprint * const BlueprintTemplate = Cast<UBlueprint>(StaticLoadObject(UBlueprint::StaticClass(), NULL, *BlueprintAssetPath));
	if (BlueprintTemplate != NULL)
	{
		// want to explicitly test switching from actors->objects, and vise versa (objects->actors), 
		// also could cover the case of changing non-native parents to native ones
		TArray<UClass*> TestParentClasses;
		if (!BlueprintTemplate->ParentClass->IsChildOf(AActor::StaticClass()))
		{
			TestParentClasses.Add(AActor::StaticClass());
		}
		else
		{
			// not many engine level Blueprintable classes that aren't Actors
			TestParentClasses.Add(USaveGame::StaticClass());
		}

		TArray<FAssetData> Assets;
		FBlueprintAutomationTestUtilities::GetAssetListingFromConfig(TEXT("ReparentTest.ParentsPackagePaths"), Assets, UBlueprint::StaticClass());
		// additionally gather up any blueprints that we explicitly specify though the config
		for (FAssetData const& AssetData : Assets)
		{
			UClass* AssetClass = FindObject<UClass>(ANY_PACKAGE, *AssetData.AssetClass.ToString());
			TestParentClasses.Add(AssetClass);
		}

		for (UClass* Class : TestParentClasses)
		{		 
			UBlueprint* BlueprintObj = FBlueprintAutomationTestUtilities::DuplicateBlueprint(BlueprintTemplate);
			check(BlueprintObj != NULL);
			BlueprintObj->ParentClass = Class;

			if (!FBlueprintAutomationTestUtilities::TestSaveBlueprint(BlueprintObj))
			{
				AddError(FString::Printf(TEXT("Failed to save blueprint after reparenting with %s: '%s'"), *Class->GetName(), *BlueprintAssetPath));
				bTestFailed = true;
			}

			FBlueprintAutomationTestUtilities::UnloadBlueprint(BlueprintObj);
		}

#if WITH_EDITOR
		// clear undo history to ensure that the transaction buffer isn't 
		// holding onto any references to the blueprints we want unloaded
		GEditor->Trans->Reset(NSLOCTEXT("BpAutomation", "ReparentTest", "Reparent Blueprint Test"));
#endif // #if WITH_EDITOR
		// make sure the unloaded blueprints are properly flushed (for future tests)
		CollectGarbage(RF_Native);
	}

	return !bTestFailed;
}
void UESpriterFileDocumentWrapper::loadFile(std::string fileName)
{
	if (xmlFile != NULL)
	{
		delete xmlFile;
	}
	
	USpriterProject *project = Cast<USpriterProject>(StaticLoadObject(USpriterProject::StaticClass(), NULL, ANSI_TO_TCHAR(fileName.c_str())));

	xmlFile = new FXmlFile(project->Content, EConstructMethod::ConstructFromBuffer);
}
FSpriteGeometryEditingHelper::FSpriteGeometryEditingHelper(ISpriteSelectionContext* InEditorContext)
	: EditorContext(InEditorContext)
	, GeometryBeingEdited(nullptr)
	, bIsAddingPolygon(false)
	, AddingPolygonIndex(INDEX_NONE)
	, bShowNormals(true)
	, bAllowSubtractivePolygons(false)
	, bAllowCircles(true)
{
	WidgetVertexColorMaterial = (UMaterial*)StaticLoadObject(UMaterial::StaticClass(), NULL, TEXT("/Engine/EditorMaterials/WidgetVertexColorMaterial.WidgetVertexColorMaterial"), NULL, LOAD_None, NULL);
}
예제 #21
0
void ASDBXGameMode::SetSongLoop()
{
    //Set the song loop to play
    USDBXGameInstance* GInstance = Cast<USDBXGameInstance>(GetGameInstance());
    FString name = GInstance->GetSongName();
    name = name.Replace(TEXT(" "), TEXT(""));
    name = name.Replace(TEXT("("), TEXT(""));
    name = name.Replace(TEXT(")"), TEXT(""));
    FString SoundCuePath = "/Game/Audio/" + name + "." + name;
    songLoop = Cast<USoundCue>(StaticLoadObject(USoundCue::StaticClass(), NULL, *SoundCuePath));
    UE_LOG(LogTemp, Warning, TEXT("%s"), *SoundCuePath);
}
예제 #22
0
UObject* UAirBlueprintLib::LoadObject(const std::string& name)
{
    FString str(name.c_str());
    UObject *obj = StaticLoadObject(UObject::StaticClass(), nullptr, *str);
    if (obj == nullptr) {
        std::string msg = "Failed to load asset object - " + name;
        FString fmsg(msg.c_str());
        LogMessage(TEXT("Load: "), fmsg, LogDebugLevel::Failure);
        throw std::invalid_argument(msg);
    }
    return obj;
}
예제 #23
0
/**
* Latent command that adds a static mesh to the worlds origin.
*/
bool FAddStaticMeshCommand::Update()
{
	//Gather assets.
	UObject* Cube = (UStaticMesh*)StaticLoadObject(UStaticMesh::StaticClass(), NULL, TEXT("/Engine/EngineMeshes/Cube.Cube"), NULL, LOAD_None, NULL);
	//Add Cube mesh to the world
	AStaticMeshActor* StaticMesh = Cast<AStaticMeshActor>(FActorFactoryAssetProxy::AddActorForAsset(Cube));
	StaticMesh->TeleportTo(FVector(0.0f, 0.0f, 0.0f), FRotator(0, 0, 0));
	StaticMesh->SetActorRelativeScale3D(FVector(1.0f, 1.0f, 1.0f));

	UE_LOG(LogEditorAutomationTests, Log, TEXT("Static Mesh cube has been added to 0, 0, 0."))

		return true;
}
bool FOpenAllofAssetTypeCommand::Update()
{
	if ((FPlatformTime::Seconds() - AssetList.TimeSpent) > ASSET_OPEN_INTERVAL)
	{
		FAssetEditorManager::Get().CloseAllAssetEditors();

		//Get all assets currently being tracked with open editors and make sure they are not opened.
		if (FAssetEditorManager::Get().GetAllEditedAssets().Num() > 0)
		{
			UE_LOG(LogEditorAutomationTests, Warning, TEXT("Not all of the editors were closed."));
		}

		CollectGarbage(GARBAGE_COLLECTION_KEEPFLAGS);

		UE_LOG(LogEditorAutomationTests, Log, TEXT("Remaining assets to open: %i"), AssetList.AssetPathList.Num() - AssetList.AssetListLength);

		if (AssetList.AssetListLength < AssetList.AssetPathList.Num())
		{
			UObject* Object = StaticLoadObject(UObject::StaticClass(), NULL, *AssetList.AssetPathList[AssetList.AssetListLength]);
			if (Object)
			{
				FAssetEditorManager::Get().OpenEditorForAsset(Object);
				//This checks to see if the asset sub editor is loaded.
				if (FAssetEditorManager::Get().FindEditorForAsset(Object, true) != NULL)
				{
					UE_LOG(LogEditorAutomationTests, Log, TEXT("Verified asset editor for: %s."), *AssetList.AssetPathList[AssetList.AssetListLength]);
					UE_LOG(LogEditorAutomationTests, Display, TEXT("The editor successffully loaded for: %s."), *AssetList.AssetPathList[AssetList.AssetListLength]);
					if (GShaderCompilingManager->IsCompiling())
					{
						UE_LOG(LogEditorAutomationTests, Log, TEXT("Waiting for %i shaders to finish."), GShaderCompilingManager->GetNumRemainingJobs());
						GShaderCompilingManager->FinishAllCompilation();
						UE_LOG(LogEditorAutomationTests, Log, TEXT("Done waiting for shaders to finish."));
					}
				}
			}
			else
			{
				UE_LOG(LogEditorAutomationTests, Error, TEXT("Failed to find object: %s."), *AssetList.AssetPathList[AssetList.AssetListLength]);
			}
			AssetList.AssetListLength++;
			AssetList.TimeSpent = FPlatformTime::Seconds();
			return false;
		}
		else
		{
			return true;
		}
	}
		return false;
}
UObject* UPathFollowerBlueprintFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn, FName CallingContext)
{
	check(Class->IsChildOf(UPathFollowerBlueprint::StaticClass()));
	UPathFollowerBlueprint* NewBP = CastChecked<UPathFollowerBlueprint>(FKismetEditorUtilities::CreateBlueprint(ACharacter::StaticClass(), InParent, Name, EBlueprintType::BPTYPE_Normal, UPathFollowerBlueprint::StaticClass(), UPathFollowerBlueprintGeneratedClass::StaticClass(), CallingContext));

	//默认从另外一个蓝图中Copy过来, 省去需要重新创建蓝图内容.
	FString bpFile = TEXT("/PathFollower/FollowSplinePath");
	UObject* loadedObject = StaticLoadObject(UObject::StaticClass(), nullptr, *bpFile);
	UBlueprint* castedBlueprint = Cast<UBlueprint>(loadedObject);
	UBlueprint* ret = FKismetEditorUtilities::ReplaceBlueprint(NewBP, castedBlueprint);

	if (ret != nullptr)
		return ret;

	return NewBP;
}
bool FOpenActualAssetEditors(const FString& Parameters)
{
	//start with all editors closed
	FAssetEditorManager::Get().CloseAllAssetEditors();

	// below is all latent action, so before sending there, verify the asset exists
	UObject* Object = StaticLoadObject(UObject::StaticClass(), NULL, *Parameters);
	if (!Object)
	{
		UE_LOG(LogEditorAutomationTests, Error, TEXT("Failed to find object: %s."), *Parameters);
		return false;
	}

	ADD_LATENT_AUTOMATION_COMMAND(FOpenEditorForAssetCommand(*Parameters));
	ADD_LATENT_AUTOMATION_COMMAND(FWaitLatentCommand(0.5f));
	ADD_LATENT_AUTOMATION_COMMAND(FCloseAllAssetEditorsCommand());

	return true;
}
  //---------------------------------------------------------------------------------------
  // Entity@load(String name) ThisClass_
  static void mthdc_load(SkInvokedMethod * scope_p, SkInstance ** result_pp)
    {
    if (result_pp) // Do nothing if result not desired
      {
      // Determine class of object to load
      SkClass * class_p = &((SkMetaClass *)scope_p->get_topmost_scope())->get_class_info();
      UClass * uclass_p = SkUEClassBindingHelper::get_ue_class_from_sk_class(class_p);
      SK_ASSERTX(uclass_p, a_cstr_format("Cannot load entity '%s' as the UE4 equivalent of class type '%s' is not known to SkookumScript.", scope_p->get_arg<SkString>(SkArg_1).as_cstr(), class_p->get_name_cstr_dbg()));

      // Load object
      UObject * obj_p = nullptr;
      if (uclass_p)
        {
        obj_p = StaticLoadObject(uclass_p, SkUEClassBindingHelper::get_world(), *AStringToFString(scope_p->get_arg<SkString>(SkArg_1)));
        }

      *result_pp = obj_p ? SkUEEntity::new_instance(obj_p, uclass_p, class_p) : SkBrain::ms_nil_p;
      }
    }
예제 #28
0
/**
* Open editor for a particular asset
*/
bool FOpenEditorForAssetCommand::Update()
{
	UObject* Object = StaticLoadObject(UObject::StaticClass(), NULL, *AssetName);
	if (Object)
	{
		FAssetEditorManager::Get().OpenEditorForAsset(Object);
		//This checks to see if the asset sub editor is loaded.
		if (FAssetEditorManager::Get().FindEditorForAsset(Object, true) != NULL)
		{
			UE_LOG(LogEditorAutomationTests, Log, TEXT("Verified asset editor for: %s."), *AssetName);
			UE_LOG(LogEditorAutomationTests, Display, TEXT("The editor successffully loaded for: %s."), *AssetName);
			return true;
		}
	}
	else
	{
		UE_LOG(LogEditorAutomationTests, Error, TEXT("Failed to find object: %s."), *AssetName);
	}
	return true;
}
void FPaperJsonSpriteSheetImporter::SetReimportData(const TArray<FString>& ExistingSpriteNames, const TArray< TAssetPtr<class UPaperSprite> >& ExistingSpriteAssetPtrs)
{
	check(ExistingSpriteNames.Num() == ExistingSpriteAssetPtrs.Num());
	if (ExistingSpriteNames.Num() == ExistingSpriteAssetPtrs.Num())
	{
		for (int i = 0; i < ExistingSpriteAssetPtrs.Num(); ++i)
		{
			const TAssetPtr<class UPaperSprite> SpriteAssetPtr = ExistingSpriteAssetPtrs[i];
			FStringAssetReference SpriteStringRef = SpriteAssetPtr.ToStringReference();
			if (!SpriteStringRef.ToString().IsEmpty())
			{
				UPaperSprite* LoadedSprite = Cast<UPaperSprite>(StaticLoadObject(UPaperSprite::StaticClass(), nullptr, *SpriteStringRef.ToString(), nullptr, LOAD_None, nullptr));
				if (LoadedSprite != nullptr)
				{
					ExistingSprites.Add(ExistingSpriteNames[i], LoadedSprite);
				}
			}
		}
	}
	bIsReimporting = true;
}
  //---------------------------------------------------------------------------------------
  // Entity@load(String name) ThisClass_
  static void mthdc_load(SkInvokedMethod * scope_p, SkInstance ** result_pp)
    {
    // Load it regardless if a result is desired

    // Determine class of object to load
    SkClass * sk_class_p = ((SkMetaClass *)scope_p->get_topmost_scope())->get_class_info();
    UClass * ue_class_p = SkUEClassBindingHelper::get_ue_class_from_sk_class(sk_class_p);
    SK_ASSERTX(ue_class_p, a_cstr_format("Cannot load entity '%s' as the UE4 equivalent of class type '%s' is not known to SkookumScript. Maybe it is the class of a Blueprint that is not loaded yet?", scope_p->get_arg<SkString>(SkArg_1).as_cstr(), sk_class_p->get_name_cstr_dbg()));

    // Load object
    UObject * obj_p = nullptr;
    if (ue_class_p)
      {
      obj_p = StaticLoadObject(ue_class_p, SkUEClassBindingHelper::get_world(), *AStringToFString(scope_p->get_arg<SkString>(SkArg_1)));
      }

    // Set result if desired
    if (result_pp)
      {
      *result_pp = obj_p ? SkUEEntity::new_instance(obj_p, ue_class_p, sk_class_p) : SkBrain::ms_nil_p;
      }
    }