void SPropertyEditorClass::OnClassPicked(UClass* InClass) { if(!InClass) { SendToObjects(TEXT("None")); } else { SendToObjects(InClass->GetPathName()); } ComboButton->SetIsOpen(false); }
void SPropertyEditorCombo::OnComboSelectionChanged( TSharedPtr<FString> NewValue, ESelectInfo::Type SelectInfo ) { if ( NewValue.IsValid() ) { SendToObjects( *NewValue ); } }
FReply SPropertyEditorClass::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) { TSharedPtr<FClassDragDropOp> ClassOperation = DragDropEvent.GetOperationAs<FClassDragDropOp>(); if (ClassOperation.IsValid()) { // We can only drop one item into the combo box, so drop the first one. FString AssetName = ClassOperation->ClassesToDrop[0]->GetName(); // Set the property, it will be verified as valid. SendToObjects(AssetName); return FReply::Handled(); } TSharedPtr<FUnloadedClassDragDropOp> UnloadedClassOp = DragDropEvent.GetOperationAs<FUnloadedClassDragDropOp>(); if (UnloadedClassOp.IsValid()) { // Check if the asset is loaded, used to see if the context menu should be available bool bAllAssetWereLoaded = true; TArray<FClassPackageData>& AssetArray = *(UnloadedClassOp->AssetsToDrop.Get()); // We can only drop one item into the combo box, so drop the first one. FString& AssetName = AssetArray[0].AssetName; // Check to see if the asset can be found, otherwise load it. UObject* Object = FindObject<UObject>(NULL, *AssetName); if(Object == NULL) { // Check to see if the dropped asset was a blueprint const FString& PackageName = AssetArray[0].GeneratedPackageName; Object = FindObject<UObject>(NULL, *FString::Printf(TEXT("%s.%s"), *PackageName, *AssetName)); if(Object == NULL) { // Load the package. GWarn->BeginSlowTask(LOCTEXT("OnDrop_LoadPackage", "Fully Loading Package For Drop"), true, false); UPackage* Package = LoadPackage(NULL, *PackageName, LOAD_NoRedirects ); if(Package) { Package->FullyLoad(); } GWarn->EndSlowTask(); Object = FindObject<UObject>(Package, *AssetName); } if(Object->IsA(UBlueprint::StaticClass())) { // Get the default object from the generated class. Object = Cast<UBlueprint>(Object)->GeneratedClass->GetDefaultObject(); } } // Set the property, it will be verified as valid. SendToObjects(AssetName); return FReply::Handled(); } return FReply::Unhandled(); }