void ARadiantWebViewActor::BindDynamicMaterial()
{
	if ((GetNetMode() != NM_DedicatedServer) && MeshComponent && (WebViewRenderComponent->WebView->WebViewCanvas))
	{
		if (OldMeshMaterial)
		{
			MeshComponent->SetMaterial(OldMaterialIndex, OldMeshMaterial);
		}

		OldMeshMaterial = MeshComponent->GetMaterial(MaterialIndex);

		if (WebViewMID)
		{
			WebViewMID->MarkPendingKill();
		}

		if (ReplaceMaterial)
		{
			WebViewMID = UMaterialInstanceDynamic::Create(ReplaceMaterial, GetTransientPackage());
		}
		else if (OldMeshMaterial)
		{
			WebViewMID = UMaterialInstanceDynamic::Create(OldMeshMaterial, GetTransientPackage());
		}

		if (WebViewMID)
		{
			WebViewMID->SetTextureParameterValue(TEXT("WebViewTexture"), WebViewRenderComponent->WebView->WebViewCanvas->RenderTargetTexture);
		}
	}
}
Beispiel #2
0
FPreviewScene::FPreviewScene(FPreviewScene::ConstructionValues CVS)
	: PreviewWorld(NULL)
	, bForceAllUsedMipsResident(CVS.bForceMipsResident)
{
	PreviewWorld = NewObject<UWorld>();
	PreviewWorld->WorldType = EWorldType::Preview;
	if (CVS.bTransactional)
	{
		PreviewWorld->SetFlags(RF_Transactional);
	}

	FWorldContext& WorldContext = GEngine->CreateNewWorldContext(EWorldType::Preview);
	WorldContext.SetCurrentWorld(PreviewWorld);

	PreviewWorld->InitializeNewWorld(UWorld::InitializationValues()
										.AllowAudioPlayback(CVS.bAllowAudioPlayback)
										.CreatePhysicsScene(CVS.bCreatePhysicsScene)
										.RequiresHitProxies(false)
										.CreateNavigation(false)
										.CreateAISystem(false)
										.ShouldSimulatePhysics(CVS.bShouldSimulatePhysics)
										.SetTransactional(CVS.bTransactional));
	PreviewWorld->InitializeActorsForPlay(FURL());

	GetScene()->UpdateDynamicSkyLight(FLinearColor::White * CVS.SkyBrightness, FLinearColor::Black);

	DirectionalLight = NewObject<UDirectionalLightComponent>(GetTransientPackage());
	DirectionalLight->Intensity = CVS.LightBrightness;
	DirectionalLight->LightColor = FColor::White;
	AddComponent(DirectionalLight, FTransform(CVS.LightRotation));

	LineBatcher = NewObject<ULineBatchComponent>(GetTransientPackage());
	AddComponent(LineBatcher, FTransform::Identity);
}
Beispiel #3
0
/**
 * Marks/Unmarks the package's bDirty flag
 */
void UPackage::SetDirtyFlag( bool bIsDirty )
{
	if ( GetOutermost() != GetTransientPackage() )
	{
		if ( GUndo != NULL
		// PIE world objects should never end up in the transaction buffer as we cannot undo during gameplay.
		&& !(GetOutermost()->PackageFlags & (PKG_PlayInEditor|PKG_ContainsScript)) )
		{
			// make sure we're marked as transactional
			SetFlags(RF_Transactional);

			// don't call Modify() since it calls SetDirtyFlag()
			GUndo->SaveObject( this );
		}

		// Update dirty bit
		bDirty = bIsDirty;

		if( GIsEditor									// Only fire the callback in editor mode
			&& !(PackageFlags & PKG_ContainsScript)		// Skip script packages
			&& !(PackageFlags & PKG_PlayInEditor)		// Skip packages for PIE
			&& GetTransientPackage() != this )			// Skip the transient package
		{
			// Package is changing dirty state, let the editor know so we may prompt for source control checkout
			PackageDirtyStateChangedEvent.Broadcast(this);
		}
	}
}
UMaterialShaderQualitySettings* UMaterialShaderQualitySettings::Get()
{
	if( RenderQualitySingleton == nullptr )
	{
		static const TCHAR* SettingsContainerName = TEXT("MaterialShaderQualitySettingsContainer");

		RenderQualitySingleton = FindObject<UMaterialShaderQualitySettings>(GetTransientPackage(), SettingsContainerName);

		if (RenderQualitySingleton == nullptr)
		{
			RenderQualitySingleton = NewObject<UMaterialShaderQualitySettings>(GetTransientPackage(), UMaterialShaderQualitySettings::StaticClass(), SettingsContainerName);
			RenderQualitySingleton->AddToRoot();
		}
		RenderQualitySingleton->CurrentPlatformSettings = RenderQualitySingleton->GetShaderPlatformQualitySettings(FPlatformProperties::PlatformName());

		// LegacyShaderPlatformToShaderFormat(EShaderPlatform)
		// GShaderPlatformForFeatureLevel
		// GMaxRHIFeatureLevel

		// populate shader platforms
		RenderQualitySingleton->CurrentPlatformSettings = RenderQualitySingleton->GetShaderPlatformQualitySettings(FPlatformProperties::PlatformName());

	}
	return RenderQualitySingleton;
}
	static void ReplaceStructWithTempDuplicate(
		UUserDefinedStruct* StructureToReinstance, 
		TSet<UBlueprint*>& BlueprintsToRecompile,
		TArray<UUserDefinedStruct*>& ChangedStructs)
	{
		if (StructureToReinstance)
		{
			UUserDefinedStruct* DuplicatedStruct = NULL;
			{
				const FString ReinstancedName = FString::Printf(TEXT("STRUCT_REINST_%s"), *StructureToReinstance->GetName());
				const FName UniqueName = MakeUniqueObjectName(GetTransientPackage(), UUserDefinedStruct::StaticClass(), FName(*ReinstancedName));

				TGuardValue<bool> IsDuplicatingClassForReinstancing(GIsDuplicatingClassForReinstancing, true);
				DuplicatedStruct = (UUserDefinedStruct*)StaticDuplicateObject(StructureToReinstance, GetTransientPackage(), *UniqueName.ToString(), ~RF_Transactional); 
			}

			DuplicatedStruct->Guid = StructureToReinstance->Guid;
			DuplicatedStruct->Bind();
			DuplicatedStruct->StaticLink(true);
			DuplicatedStruct->PrimaryStruct = StructureToReinstance;
			DuplicatedStruct->Status = EUserDefinedStructureStatus::UDSS_Duplicate;
			DuplicatedStruct->SetFlags(RF_Transient);
			DuplicatedStruct->AddToRoot();
			CastChecked<UUserDefinedStructEditorData>(DuplicatedStruct->EditorData)->RecreateDefaultInstance();

			for (auto StructProperty : TObjectRange<UStructProperty>(RF_ClassDefaultObject | RF_PendingKill))
			{
				if (StructProperty && (StructureToReinstance == StructProperty->Struct))
				{
					if (auto OwnerClass = Cast<UBlueprintGeneratedClass>(StructProperty->GetOwnerClass()))
					{
						if (UBlueprint* FoundBlueprint = Cast<UBlueprint>(OwnerClass->ClassGeneratedBy))
						{
							BlueprintsToRecompile.Add(FoundBlueprint);
							StructProperty->Struct = DuplicatedStruct;
						}
					}
					else if (auto OwnerStruct = Cast<UUserDefinedStruct>(StructProperty->GetOwnerStruct()))
					{
						check(OwnerStruct != DuplicatedStruct);
						const bool bValidStruct = (OwnerStruct->GetOutermost() != GetTransientPackage())
							&& !OwnerStruct->HasAnyFlags(RF_PendingKill)
							&& (EUserDefinedStructureStatus::UDSS_Duplicate != OwnerStruct->Status.GetValue());

						if (bValidStruct)
						{
							ChangedStructs.AddUnique(OwnerStruct);
							StructProperty->Struct = DuplicatedStruct;
						}
					}
					else
					{
						UE_LOG(LogK2Compiler, Error, TEXT("ReplaceStructWithTempDuplicate unknown owner"));
					}
				}
			}

			DuplicatedStruct->RemoveFromRoot();
		}
	}
Beispiel #6
0
void FTexAlignTools::Init()
{
	// Create the list of aligners.
	Aligners.Empty();
	Aligners.Add(NewObject<UTexAlignerDefault>(GetTransientPackage(), NAME_None, RF_Public | RF_RootSet | RF_Standalone));
	Aligners.Add(NewObject<UTexAlignerPlanar>(GetTransientPackage(), NAME_None, RF_Public | RF_RootSet | RF_Standalone));
	Aligners.Add(NewObject<UTexAlignerBox>(GetTransientPackage(), NAME_None, RF_Public | RF_RootSet | RF_Standalone));
	Aligners.Add(NewObject<UTexAlignerFit>(GetTransientPackage(), NAME_None, RF_Public | RF_RootSet | RF_Standalone));
	
	FEditorDelegates::FitTextureToSurface.AddRaw(this, &FTexAlignTools::OnEditorFitTextureToSurface);
}
UObject* FEditorObjectTracker::GetEditorObjectForClass( UClass* EdClass )
{
	UObject *Obj = (EditorObjMap.Contains(EdClass) ? *EditorObjMap.Find(EdClass) : NULL);
	if(Obj == NULL)
	{
		FString ObjName = MakeUniqueObjectName(GetTransientPackage(), EdClass).ToString();
		ObjName += "_EdObj";
		Obj = StaticConstructObject(EdClass, GetTransientPackage(), FName(*ObjName), RF_Public|RF_Standalone|RF_Transient);
		EditorObjMap.Add(EdClass,Obj);
	}
	return Obj;
}
void UChildActorComponent::PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent)
{
	if (PropertyChangedEvent.Property && PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UChildActorComponent, ChildActorClass))
	{
		if (IsTemplate())
		{
			if (ChildActorClass)
			{
				if (ChildActorTemplate == nullptr || (ChildActorTemplate->GetClass() != ChildActorClass))
				{
					Modify();

					AActor* NewChildActorTemplate = NewObject<AActor>(GetTransientPackage(), ChildActorClass, NAME_None, RF_ArchetypeObject | RF_Transactional | RF_Public);

					if (ChildActorTemplate)
					{
						UEngine::CopyPropertiesForUnrelatedObjects(ChildActorTemplate, NewChildActorTemplate);

						ChildActorTemplate->Rename(nullptr, GetTransientPackage(), REN_DontCreateRedirectors);
					}

					ChildActorTemplate = NewChildActorTemplate;

					// Record initial object state in case we're in a transaction context.
					ChildActorTemplate->Modify();

					// Now set the actual name and outer to the BPGC.
					const FString TemplateName = FString::Printf(TEXT("%s_%s_CAT"), *GetName(), *ChildActorClass->GetName());

					ChildActorTemplate->Rename(*TemplateName, this, REN_DoNotDirty | REN_DontCreateRedirectors | REN_ForceNoResetLoaders);
				}
			}
			else if (ChildActorTemplate)
			{
				Modify();

				ChildActorTemplate->Rename(nullptr, GetTransientPackage(), REN_DontCreateRedirectors);
				ChildActorTemplate = nullptr;
			}
		}
		else
		{
			ChildActorTemplate = CastChecked<UChildActorComponent>(GetArchetype())->ChildActorTemplate;
		}
	}

	Super::PostEditChangeChainProperty(PropertyChangedEvent);
}
Beispiel #9
0
void UK2Node::ReconstructSinglePin(UEdGraphPin* NewPin, UEdGraphPin* OldPin, ERedirectType RedirectType)
{
	UBlueprint* Blueprint = GetBlueprint();

	check(NewPin && OldPin);

	// Copy over modified persistent data
	NewPin->CopyPersistentDataFromOldPin(*OldPin);

	if (NewPin->DefaultValue != NewPin->AutogeneratedDefaultValue)
	{
		if (RedirectType == ERedirectType_Value)
		{
			TArray<FString> OldPinNames;
			GetRedirectPinNames(*OldPin, OldPinNames);

			// convert TArray<FString> to TArray<FName>, faster to search
			TArray<FName> OldPinFNames;
			for (auto NameIter=OldPinNames.CreateConstIterator(); NameIter; ++NameIter)
			{
				const FString& Name = *NameIter;
				OldPinFNames.AddUnique(*Name);
			}

			// go through for the NewPinNode
			for(TMultiMap<UClass*, FParamRemapInfo>::TConstKeyIterator ParamIter(FMemberReference::GetParamRedirectMap(), Cast<UK2Node>(NewPin->GetOwningNode())->GetClass()); ParamIter; ++ParamIter)
			{
				const FParamRemapInfo& ParamRemap = ParamIter.Value();

				// once we find it, see about remapping the value
				if (OldPinFNames.Contains(ParamRemap.OldParam))
				{
					const FString* NewValue = ParamRemap.ParamValueMap.Find(NewPin->DefaultValue);
					if (NewValue)
					{
						NewPin->DefaultValue = *NewValue;
					}
					break;
				}
			}
		}
		else if (RedirectType == ERedirectType_Custom)
		{
			CustomMapParamValue(*NewPin);
		}
	}

	// Update the blueprints watched pins as the old pin will be going the way of the dodo
	for (int32 WatchIndex = 0; WatchIndex < Blueprint->PinWatches.Num(); ++WatchIndex)
	{
		UEdGraphPin*& WatchedPin = Blueprint->PinWatches[WatchIndex];
		if( WatchedPin == OldPin )
		{
			WatchedPin = NewPin;
			break;
		}
	}

	OldPin->Rename(NULL, GetTransientPackage(), (REN_DontCreateRedirectors|(Blueprint->bIsRegeneratingOnLoad ? REN_ForceNoResetLoaders : REN_None)));
}
bool UDeckListModel::LoadDecks(UCardListModel* CardListModel, UHeroListModel* HeroListModel)
{
	TArray<UCardDeckModel*> Result;
	UParagonSaveGame* LoadedSaveGame = Cast<UParagonSaveGame>(UGameplayStatics::CreateSaveGameObject(UParagonSaveGame::StaticClass()));
	LoadedSaveGame = Cast<UParagonSaveGame>(UGameplayStatics::LoadGameFromSlot(TEXT("DefaultSaveGameSlot"), 0));
	if (!LoadedSaveGame)
	{
		return false;
	}

	auto Importer = NewObject<UCardDeckImporterJSON>(GetTransientPackage(), NAME_None);

	for (auto& DeckAsJSON : LoadedSaveGame->DecksAsJSON)
	{
		if (DeckAsJSON.IsEmpty())
		{
			Result.Add(nullptr);
		}
		else
		{
			TArray<FString> ImportErrors;
			UCardDeckModel* CardDeckModel = Importer->ImportDeckModel(DeckAsJSON, CardListModel, HeroListModel, ImportErrors);
			if (!CardDeckModel)
			{
				return false;
			}
			Result.Add(CardDeckModel);
		}
	}

	DeckSlots = Result;
	return true;
}
FAISenseID UAISense_Blueprint::UpdateSenseID()
{
#if WITH_EDITOR
	// ignore skeleton and "old version"-classes
	if (FKismetEditorUtilities::IsClassABlueprintSkeleton(GetClass()) || GetClass()->HasAnyClassFlags(CLASS_NewerVersionExists)
		|| (GetOutermost() == GetTransientPackage()))
	{
		return FAISenseID::InvalidID();
	}
#endif
	if (GetClass()->HasAnyClassFlags(CLASS_Abstract) == false)
	{
		const NAME_INDEX NameIndex = GetClass()->GetFName().GetDisplayIndex();
		const FAISenseID* StoredID = BPSenseToSenseID.Find(NameIndex);
		if (StoredID != nullptr)
		{
			ForceSenseID(*StoredID);
		}
		else
		{
			const FAISenseID NewSenseID = FAISenseID(GetFName());
			ForceSenseID(NewSenseID);
			BPSenseToSenseID.Add(NameIndex, GetSenseID());
		}
	}

	return GetSenseID();
}
//------------------------------------------------------------------------------
UBlueprintComponentNodeSpawner* UBlueprintComponentNodeSpawner::Create(TSubclassOf<UActorComponent> const ComponentClass, UObject* Outer/* = nullptr*/)
{
	check(ComponentClass != nullptr);

	if (Outer == nullptr)
	{
		Outer = GetTransientPackage();
	}

	UBlueprintComponentNodeSpawner* NodeSpawner = NewObject<UBlueprintComponentNodeSpawner>(Outer);
	NodeSpawner->ComponentClass = ComponentClass;
	NodeSpawner->NodeClass      = UK2Node_AddComponent::StaticClass();

	FBlueprintActionUiSpec& MenuSignature = NodeSpawner->DefaultMenuSignature;
	FText const ComponentTypeName = FText::FromName(ComponentClass->GetFName());
	MenuSignature.MenuName = FText::Format(LOCTEXT("AddComponentMenuName", "Add {0}"), ComponentTypeName);
	MenuSignature.Category = BlueprintComponentNodeSpawnerImpl::GetDefaultMenuCategory(ComponentClass);
	MenuSignature.Tooltip  = FText::Format(LOCTEXT("AddComponentTooltip", "Spawn a {0}"), ComponentTypeName);
	MenuSignature.Keywords = ComponentClass->GetMetaData(FBlueprintMetadata::MD_FunctionKeywords);
	// add at least one character, so that PrimeDefaultMenuSignature() doesn't 
	// attempt to query the template node
	MenuSignature.Keywords.AppendChar(TEXT(' '));
	MenuSignature.IconName = FClassIconFinder::FindIconNameForClass(ComponentClass);

	return NodeSpawner;
}
//------------------------------------------------------------------------------
UBlueprintEventNodeSpawner* UBlueprintEventNodeSpawner::Create(TSubclassOf<UK2Node_Event> NodeClass, FName CustomEventName, UObject* Outer/* = nullptr*/)
{
	if (Outer == nullptr)
	{
		Outer = GetTransientPackage();
	}

	UBlueprintEventNodeSpawner* NodeSpawner = NewObject<UBlueprintEventNodeSpawner>(Outer);
	NodeSpawner->NodeClass       = NodeClass;
	NodeSpawner->CustomEventName = CustomEventName;

	FBlueprintActionUiSpec& MenuSignature = NodeSpawner->DefaultMenuSignature;
	if (CustomEventName.IsNone())
	{
		MenuSignature.MenuName = LOCTEXT("AddCustomEvent", "Add Custom Event...");
		MenuSignature.IconName = TEXT("GraphEditor.CustomEvent_16x");
	}
	else
	{
		FText const EventName = FText::FromName(CustomEventName);
		MenuSignature.MenuName = FText::Format(LOCTEXT("EventWithSignatureName", "Event {0}"), EventName);
		MenuSignature.IconName = TEXT("GraphEditor.Event_16x");
	}
	//MenuSignature.Category, will be pulled from the node template
	//MenuSignature.Tooltip,  will be pulled from the node template 
	//MenuSignature.Keywords, will be pulled from the node template

	return NodeSpawner;
}
Beispiel #14
0
void FAnimMontageInstance::AddReferencedObjects( FReferenceCollector& Collector )
{
	if (Montage && Montage->GetOuter() == GetTransientPackage())
	{
		Collector.AddReferencedObject(Montage);
	}
}
	virtual void StartupModule() override
	{
		// this is an example of a hotfix, declared here for no particular reason. Once we have other examples, it can be deleted.
#if 0
		FCoreDelegates::GetHotfixDelegate(EHotfixDelegates::Test).BindRaw(this, &FWindowsTargetPlatformModule::HotfixTest);
#endif

		TargetSettings = NewObject<UWindowsTargetSettings>(GetTransientPackage(), "WindowsTargetSettings", RF_Standalone);
		
		// We need to manually load the config properties here, as this module is loaded before the UObject system is setup to do this
		GConfig->GetArray(TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("TargetedRHIs"), TargetSettings->TargetedRHIs, GEngineIni);

		// When this is initialized the UEnum for EMinimumSupportedOS hasn't been registered. 
		FString MinOSString;
		if (GConfig->GetString(TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("MinimumOSVersion"), MinOSString, GEngineIni))
		{
			// We need to parse the string and compare manually.
			TargetSettings->MinimumOSVersion = MinOSString == TEXT("MSOS_XP") ? EMinimumSupportedOS::MSOS_XP : EMinimumSupportedOS::MSOS_Vista;
		}


		TargetSettings->AddToRoot();

		ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");

		if (SettingsModule != nullptr)
		{
			SettingsModule->RegisterSettings("Project", "Platforms", "Windows",
				LOCTEXT("TargetSettingsName", "Windows"),
				LOCTEXT("TargetSettingsDescription", "Settings for Windows target platform"),
				TargetSettings
			);
		}
	}
// Called when the game starts
void UTestLoadCSVComponent::BeginPlay()
{
	Super::BeginPlay();

	// ...
	
	// 加载csv,并且显示第一行数据
	UDataTable* csv = LoadObject<UDataTable>(NULL, TEXT("DataTable'/Game/csv/test1.test1'"));
	if (csv != NULL && csv->GetRowNames().Num() > 0)
	{
		// 获取id=1的那行的数据
		FTestDataRow* row = csv->FindRow<FTestDataRow>(TEXT("1"), TEXT(""));
		if (row != NULL)
		{
			Debug(FString::Printf(TEXT("csv, row time="), row->time));
		}
	}

	// 动态读取csv文件,不过,这个只能在Editor模式运行,如果需要在发布版中运行,那么自己新建一个类
	FString FilePath = FPaths::ConvertRelativePathToFull(FPaths::GameDir()) + FString::Printf(TEXT("csv/test1.csv"));
	FString Data;
	if (FFileHelper::LoadFileToString(Data, *FilePath))
	{
		UDataTable* DataTable = NewObject<UDataTable>(GetTransientPackage(), FName(TEXT("CSV_Test")));
		DataTable->RowStruct = FTestDataRow::StaticStruct();
		DataTable->CreateTableFromCSVString(Data);
		Debug(FString::Printf(TEXT("%d"), DataTable->GetRowNames().Num()));
	}
}
// Clones (deep copies) a UEdGraph, including all of it's nodes and pins and their links,
// maintaining a mapping from the clone to the source nodes (even across multiple clonings)
UEdGraph* FEdGraphUtilities::CloneGraph(UEdGraph* InSource, UObject* NewOuter, FCompilerResultsLog* MessageLog, bool bCloningForCompile)
{
	// Duplicate the graph, keeping track of what was duplicated
	TMap<UObject*, UObject*> DuplicatedObjectList;

	UObject* UseOuter = (NewOuter != NULL) ? NewOuter : GetTransientPackage();
	FObjectDuplicationParameters Parameters(InSource, UseOuter);
	Parameters.CreatedObjects = &DuplicatedObjectList;

	if (bCloningForCompile || (NewOuter == NULL))
	{
		Parameters.ApplyFlags |= RF_Transient;
	}

	UEdGraph* ClonedGraph = CastChecked<UEdGraph>(StaticDuplicateObjectEx(Parameters));

	// Store backtrack links from each duplicated object to the original source object
	if (MessageLog != NULL)
	{
		for (TMap<UObject*, UObject*>::TIterator It(DuplicatedObjectList); It; ++It)
		{
			UObject* const Source = It.Key();
			UObject* const Dest = It.Value();

			MessageLog->NotifyIntermediateObjectCreation(Dest, Source);
		}
	}

	return ClonedGraph;
}
void SStaticMeshEditorViewport::Construct(const FArguments& InArgs)
{
	StaticMeshEditorPtr = InArgs._StaticMeshEditor;

	StaticMesh = InArgs._ObjectToEdit;

	CurrentViewMode = VMI_Lit;

	SEditorViewport::Construct( SEditorViewport::FArguments() );

	PreviewMeshComponent = ConstructObject<UStaticMeshComponent>(
		UStaticMeshComponent::StaticClass(), GetTransientPackage(), NAME_None, RF_Transient );

	SetPreviewMesh(StaticMesh);

	ViewportOverlay->AddSlot()
		.VAlign(VAlign_Top)
		.HAlign(HAlign_Left)
		.Padding(10)
		[
			SAssignNew(OverlayTextVerticalBox, SVerticalBox)
		];

	FCoreUObjectDelegates::OnObjectPropertyChanged.AddRaw(this, &SStaticMeshEditorViewport::OnObjectPropertyChanged);

}
//------------------------------------------------------------------------------
UBlueprintEventNodeSpawner* UBlueprintEventNodeSpawner::Create(UFunction const* const EventFunc, UObject* Outer/* = nullptr*/)
{
	check(EventFunc != nullptr);

	if (Outer == nullptr)
	{
		Outer = GetTransientPackage();
	}

	UBlueprintEventNodeSpawner* NodeSpawner = NewObject<UBlueprintEventNodeSpawner>(Outer);
	NodeSpawner->EventFunc = EventFunc;
	NodeSpawner->NodeClass = UK2Node_Event::StaticClass();

	FBlueprintActionUiSpec& MenuSignature = NodeSpawner->DefaultMenuSignature;
	FText const FuncName = UEdGraphSchema_K2::GetFriendlySignatureName(EventFunc);
	MenuSignature.MenuName = FText::Format(LOCTEXT("EventWithSignatureName", "Event {0}"), FuncName);
	MenuSignature.Category = UK2Node_CallFunction::GetDefaultCategoryForFunction(EventFunc, LOCTEXT("AddEventCategory", "Add Event"));
	//MenuSignature.Tooltip, will be pulled from the node template
	MenuSignature.Keywords = UK2Node_CallFunction::GetKeywordsForFunction(EventFunc);
	if (MenuSignature.Keywords.IsEmpty())
	{
		MenuSignature.Keywords = FText::FromString(TEXT(" "));
	}
	MenuSignature.IconName = TEXT("GraphEditor.Event_16x");

	return NodeSpawner;
}
void FAssetTypeActions_EditorUtilityBlueprint::OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<class IToolkitHost> EditWithinLevelEditor)
{
	EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone;

	for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt)
	{
		if (UEditorUtilityBlueprint* Blueprint = Cast<UEditorUtilityBlueprint>(*ObjIt))
		{
			if (Blueprint->GeneratedClass->IsChildOf(UGlobalEditorUtilityBase::StaticClass()))
			{
				const UGlobalEditorUtilityBase* CDO = Blueprint->GeneratedClass->GetDefaultObject<UGlobalEditorUtilityBase>();
				if (CDO->bAutoRunDefaultAction)
				{
					// This is an instant-run blueprint, just execute it
					UGlobalEditorUtilityBase* Instance = NewObject<UGlobalEditorUtilityBase>(GetTransientPackage(), Blueprint->GeneratedClass);
					Instance->ExecuteDefaultAction();
				}
				else
				{
					// This one needs settings or has multiple actions to execute, so invoke the blutility dialog
					TSharedRef<FGlobalBlutilityDialog> NewBlutilityDialog(new FGlobalBlutilityDialog());
					NewBlutilityDialog->InitBlutilityDialog(Mode, EditWithinLevelEditor, Blueprint);
				}
			}
			else
			{
				// Edit actor blutilities
				FBlueprintEditorModule& BlueprintEditorModule = FModuleManager::LoadModuleChecked<FBlueprintEditorModule>( "Kismet" );
				TSharedRef<IBlueprintEditor> NewBlueprintEditor = BlueprintEditorModule.CreateBlueprintEditor(Mode, EditWithinLevelEditor, Blueprint, false);
			}
		}
	}
}
bool UDeckListModel::SaveDecks()
{
	auto Exporter = NewObject<UCardDeckExporterJSON>(GetTransientPackage(), NAME_None);
	TArray<FString> DecksAsJSON;

	for (auto CardDeckModel : DeckSlots)
	{
		if (CardDeckModel)
		{
			FString JSONData;
			if (!Exporter->ExportDeckModel(CardDeckModel, JSONData))
			{
				return false;
			}
			DecksAsJSON.Add(JSONData);
			UE_LOG(Deck, Verbose, TEXT("SAVE: \n%s"), *JSONData);
		}
		else
		{
			DecksAsJSON.Add(FString());
		}
	}

	UParagonSaveGame* SaveGame = Cast<UParagonSaveGame>(UGameplayStatics::CreateSaveGameObject(UParagonSaveGame::StaticClass()));
	SaveGame->DecksAsJSON = DecksAsJSON;
	return UGameplayStatics::SaveGameToSlot(SaveGame, TEXT("DefaultSaveGameSlot"), 0);
}
void FBlueprintCompileReinstancer::UpdateBytecodeReferences()
{
	BP_SCOPED_COMPILER_EVENT_STAT(EKismetReinstancerStats_UpdateBytecodeReferences);

	if(ClassToReinstance != NULL)
	{
		TMap<UObject*, UObject*> FieldMappings;
		GenerateFieldMappings(FieldMappings);

		for( auto DependentBP = Dependencies.CreateIterator(); DependentBP; ++DependentBP )
		{
			UClass* BPClass = (*DependentBP)->GeneratedClass;

			// Skip cases where the class is junk, or haven't finished serializing in yet
			if( (BPClass == ClassToReinstance)
				|| (BPClass->GetOutermost() == GetTransientPackage()) 
				|| BPClass->HasAnyClassFlags(CLASS_NewerVersionExists)
				|| (BPClass->ClassGeneratedBy && BPClass->ClassGeneratedBy->HasAnyFlags(RF_NeedLoad|RF_BeingRegenerated)) )
			{
				continue;
			}

			// For each function defined in this blueprint, run through the bytecode, and update any refs from the old properties to the new
			for( TFieldIterator<UFunction> FuncIter(BPClass, EFieldIteratorFlags::ExcludeSuper); FuncIter; ++FuncIter )
			{
				UFunction* CurrentFunction = *FuncIter;
				if( CurrentFunction->Script.Num() > 0 )
				{
					FArchiveReplaceObjectRef<UObject> ReplaceAr(CurrentFunction, FieldMappings, /*bNullPrivateRefs=*/ false, /*bIgnoreOuterRef=*/ true, /*bIgnoreArchetypeRef=*/ true);
				}
			}
		}
	}
}
Beispiel #23
0
bool FLiveEditorManager::Activate( const FString &Name )
{
	RealWorld = GWorld;
	check( LiveEditorWorld != NULL );
	GWorld = LiveEditorWorld;

	bool bSuccess = false;

	UBlueprint *Blueprint = LoadObject<UBlueprint>( NULL, *Name, NULL, 0, NULL );
	if(	Blueprint != NULL
		&& Blueprint->GeneratedClass != NULL
		&& Blueprint->GeneratedClass->IsChildOf( ULiveEditorBlueprint::StaticClass() ) )
	{
		FActiveBlueprintRecord Record;
		Record.Name = Name;

		auto Instance = NewObject<ULiveEditorBlueprint>(GetTransientPackage(), Blueprint->GeneratedClass, NAME_None, RF_Transient | RF_Public | RF_RootSet | RF_Standalone);
		Instance->DoInit();
		Record.Blueprint = Instance;

		ActiveBlueprints.Add( Record );
		bSuccess = true;
	}

	GWorld = RealWorld;
	RealWorld = NULL;

	return bSuccess;
}
Beispiel #24
0
UThumbnailManager& UThumbnailManager::Get()
{
	// Create it if we need to
	if (ThumbnailManagerSingleton == nullptr)
	{
		FString ClassName = GetDefault<UThumbnailManager>()->ThumbnailManagerClassName;
		if (!ClassName.IsEmpty())
		{
			// Try to load the specified class
			UClass* Class = LoadObject<UClass>(nullptr, *ClassName, nullptr, LOAD_None, nullptr);
			if (Class != nullptr)
			{
				// Create an instance of this class
				ThumbnailManagerSingleton = NewObject<UThumbnailManager>(GetTransientPackage(), Class);
			}
		}

		// If the class couldn't be loaded or is the wrong type, fallback to the default
		if (ThumbnailManagerSingleton == nullptr)
		{
			ThumbnailManagerSingleton = NewObject<UThumbnailManager>();
		}

		// Keep the singleton alive
		ThumbnailManagerSingleton->AddToRoot();

		// Tell it to load all of its classes
		ThumbnailManagerSingleton->Initialize();
	}

	return *ThumbnailManagerSingleton;
}
Beispiel #25
0
void UThumbnailManager::InitializeRenderTypeArray(TArray<FThumbnailRenderingInfo>& ThumbnailRendererTypes)
{
	// Loop through setting up each thumbnail entry
	for (int32 Index = 0; Index < ThumbnailRendererTypes.Num(); Index++)
	{
		FThumbnailRenderingInfo& RenderInfo = ThumbnailRendererTypes[Index];

		// Load the class that this is for
		if (RenderInfo.ClassNeedingThumbnailName.Len() > 0)
		{
			// Try to load the specified class
			RenderInfo.ClassNeedingThumbnail = LoadObject<UClass>(nullptr, *RenderInfo.ClassNeedingThumbnailName, nullptr, LOAD_None, nullptr);
		}

		if (RenderInfo.RendererClassName.Len() > 0)
		{
			// Try to create the renderer object by loading its class and
			// constructing one
			UClass* RenderClass = LoadObject<UClass>(nullptr, *RenderInfo.RendererClassName, nullptr, LOAD_None, nullptr);
			if (RenderClass != nullptr)
			{
				RenderInfo.Renderer = NewObject<UThumbnailRenderer>(GetTransientPackage(), RenderClass);
			}
		}

		// Add this to the map if it created the renderer component
		if (RenderInfo.Renderer != nullptr)
		{
			RenderInfoMap.Add(RenderInfo.ClassNeedingThumbnail, &RenderInfo);
		}
	}
}
Beispiel #26
0
void UThumbnailManager::RegisterCustomRenderer(UClass* Class, TSubclassOf<UThumbnailRenderer> RendererClass)
{
	check(Class != nullptr);
	check(*RendererClass != nullptr);

	const FString NewClassPathName = Class->GetPathName();

	// Verify that this class isn't already registered
	for (int32 Index = 0; Index < RenderableThumbnailTypes.Num(); ++Index)
	{
		if (ensure(RenderableThumbnailTypes[Index].ClassNeedingThumbnailName != NewClassPathName))
		{
		}
		else
		{
			return;
		}
	}

	// Register the new class
	FThumbnailRenderingInfo& Info = *(new (RenderableThumbnailTypes) FThumbnailRenderingInfo());
	Info.ClassNeedingThumbnailName = NewClassPathName;
	Info.ClassNeedingThumbnail = Class;
	Info.Renderer = NewObject<UThumbnailRenderer>(GetTransientPackage(), RendererClass);
	Info.RendererClassName = RendererClass->GetPathName();

	bMapNeedsUpdate = true;
}
/**
 * Constructor. Builds the list of items to ignore
 */
FFindReferencedAssets::FFindReferencedAssets(void)
{
	OnEditorMapChangeDelegateHandle = FEditorDelegates::MapChange.AddRaw(this, &FFindReferencedAssets::OnEditorMapChange);

	// Set up our ignore lists
	IgnoreClasses.Add(ULevel::StaticClass());
	IgnoreClasses.Add(UWorld::StaticClass());

	// Load the asset registry module
	FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));

	TArray<FAssetData> AssetData;
	FARFilter Filter;
	Filter.PackagePaths.Add(FName(TEXT("/Engine/EngineResources")));
	Filter.PackagePaths.Add(FName(TEXT("/Engine/EngineFonts")));
	Filter.PackagePaths.Add(FName(TEXT("/Engine/EngineMaterials")));
	Filter.PackagePaths.Add(FName(TEXT("/Engine/EditorResources")));
	Filter.PackagePaths.Add(FName(TEXT("/Engine/EditorMaterials")));
	
	AssetRegistryModule.Get().GetAssets(Filter, AssetData);

	for (int32 AssetIdx = 0; AssetIdx < AssetData.Num(); ++AssetIdx)
	{
		UPackage* Package = FindObject<UPackage>(NULL, *AssetData[AssetIdx].PackageName.ToString(), true);
		if( Package != NULL )
		{
			IgnorePackages.Add(Package);
		}
	}

	IgnorePackages.Add(GetTransientPackage());
}
UBluJsonObj* UBluBlueprintFunctionLibrary::NewBluJSONObj(UObject* WorldContextObject)
{

	UBluJsonObj* tempObj = NewObject<UBluJsonObj>(GetTransientPackage(), UBluJsonObj::StaticClass());
	tempObj->init("{}");
	
	return tempObj;

}
UBluJsonObj* UBluBlueprintFunctionLibrary::ParseJSON(const FString& JSONString)
{

	UBluJsonObj* tempObj = NewObject<UBluJsonObj>(GetTransientPackage(), UBluJsonObj::StaticClass());
	tempObj->init(JSONString);

	return tempObj;

}
UMaterialInstanceDynamic* UMaterialInstanceDynamic::Create(UMaterialInterface* ParentMaterial, UObject* InOuter)
{
	UObject* Outer = InOuter ? InOuter : GetTransientPackage();
	UMaterialInstanceDynamic* MID = NewObject<UMaterialInstanceDynamic>(Outer);
	MID->SetParentInternal(ParentMaterial, false);
	return MID;
}