void UK2Node_SpawnActorFromClass::CreatePinsForClass(UClass* InClass, TArray<UEdGraphPin*>& OutClassPins) { check(InClass != NULL); const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); const UObject* const ClassDefaultObject = InClass->GetDefaultObject(false); for (TFieldIterator<UProperty> PropertyIt(InClass, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt) { UProperty* Property = *PropertyIt; UClass* PropertyClass = CastChecked<UClass>(Property->GetOuter()); const bool bIsDelegate = Property->IsA(UMulticastDelegateProperty::StaticClass()); const bool bIsExposedToSpawn = UEdGraphSchema_K2::IsPropertyExposedOnSpawn(Property); const bool bIsSettableExternally = !Property->HasAnyPropertyFlags(CPF_DisableEditOnInstance); if( bIsExposedToSpawn && !Property->HasAnyPropertyFlags(CPF_Parm) && bIsSettableExternally && Property->HasAllPropertyFlags(CPF_BlueprintVisible) && !bIsDelegate && (NULL == FindPin(Property->GetName()) ) ) { UEdGraphPin* Pin = CreatePin(EGPD_Input, TEXT(""), TEXT(""), NULL, false, false, Property->GetName()); const bool bPinGood = (Pin != NULL) && K2Schema->ConvertPropertyToPinType(Property, /*out*/ Pin->PinType); OutClassPins.Add(Pin); if (ClassDefaultObject && Pin != NULL && K2Schema->PinDefaultValueIsEditable(*Pin)) { FString DefaultValueAsString; const bool bDefaultValueSet = FBlueprintEditorUtils::PropertyValueToString(Property, reinterpret_cast<const uint8*>(ClassDefaultObject), DefaultValueAsString); check( bDefaultValueSet ); K2Schema->TrySetDefaultValue(*Pin, DefaultValueAsString); } // Copy tooltip from the property. if (Pin != nullptr) { K2Schema->ConstructBasicPinTooltip(*Pin, Property->GetToolTipText(), Pin->PinToolTip); } } } // Change class of output pin UEdGraphPin* ResultPin = GetResultPin(); ResultPin->PinType.PinSubCategoryObject = InClass; }
void CollectPropertyData(const UObject* Ob, const UClass* StopAtClass, TArray<UProperty*>& PropertyData) { UE_LOG(LogBehaviorTree, Verbose, TEXT("Looking for runtime properties of class: %s"), *GetNameSafe(Ob->GetClass())); PropertyData.Reset(); for (UProperty* TestProperty = Ob->GetClass()->PropertyLink; TestProperty; TestProperty = TestProperty->PropertyLinkNext) { // stop when reaching base class if (TestProperty->GetOuter() == StopAtClass) { break; } // skip properties without any setup data if (TestProperty->HasAnyPropertyFlags(CPF_Transient) || TestProperty->HasAnyPropertyFlags(CPF_DisableEditOnInstance) == false) { continue; } // serialize only simple types if (CanUsePropertyType(TestProperty)) { UE_LOG(LogBehaviorTree, Verbose, TEXT("> name: '%s'"), *GetNameSafe(TestProperty)); PropertyData.Add(TestProperty); } } }
void UBehaviorTreeGraphNode::DiffProperties(UStruct* Struct, void* DataA, void* DataB, FDiffResults& Results, FDiffSingleResult& Diff) { for (TFieldIterator<UProperty> PropertyIt(Struct, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt) { UProperty* Prop = *PropertyIt; // skip properties we cant see if (!Prop->HasAnyPropertyFlags(CPF_Edit|CPF_BlueprintVisible) || Prop->HasAnyPropertyFlags(CPF_Transient) || Prop->HasAnyPropertyFlags(CPF_DisableEditOnInstance) || Prop->IsA(UFunction::StaticClass()) || Prop->IsA(UDelegateProperty::StaticClass()) || Prop->IsA(UMulticastDelegateProperty::StaticClass())) { continue; } FString ValueStringA = BlueprintNodeHelpers::DescribeProperty(Prop, Prop->ContainerPtrToValuePtr<uint8>(DataA)); FString ValueStringB = BlueprintNodeHelpers::DescribeProperty(Prop, Prop->ContainerPtrToValuePtr<uint8>(DataB)); if ( ValueStringA != ValueStringB ) { if(Results) { Diff.DisplayString = FText::Format(LOCTEXT("DIF_NodePropertyFmt", "Property Changed: {0} "), FText::FromString(Prop->GetName())); Results.Add(Diff); } } } }
bool UK2Node::CreatePinsForFunctionEntryExit(const UFunction* Function, bool bForFunctionEntry) { const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); // Create the inputs and outputs bool bAllPinsGood = true; for (TFieldIterator<UProperty> PropIt(Function); PropIt && (PropIt->PropertyFlags & CPF_Parm); ++PropIt) { UProperty* Param = *PropIt; const bool bIsFunctionInput = !Param->HasAnyPropertyFlags(CPF_OutParm) || Param->HasAnyPropertyFlags(CPF_ReferenceParm); if (bIsFunctionInput == bForFunctionEntry) { const EEdGraphPinDirection Direction = bForFunctionEntry ? EGPD_Output : EGPD_Input; UEdGraphPin* Pin = CreatePin(Direction, TEXT(""), TEXT(""), NULL, false, false, Param->GetName()); const bool bPinGood = K2Schema->ConvertPropertyToPinType(Param, /*out*/ Pin->PinType); K2Schema->SetPinDefaultValueBasedOnType(Pin); UK2Node_CallFunction::GeneratePinTooltipFromFunction(*Pin, Function); bAllPinsGood = bAllPinsGood && bPinGood; } } return bAllPinsGood; }
FString CollectPropertyDescription(const UObject* Ob, const UClass* StopAtClass, const TArray<UProperty*>& PropertyData) { FString RetString; for (UProperty* TestProperty = Ob->GetClass()->PropertyLink; TestProperty; TestProperty = TestProperty->PropertyLinkNext) { // stop when reaching base class if (TestProperty->GetOuter() == StopAtClass) { break; } // skip properties without any setup data if (TestProperty->HasAnyPropertyFlags(CPF_Transient) || TestProperty->HasAnyPropertyFlags(CPF_DisableEditOnInstance) || PropertyData.Contains(TestProperty)) { continue; } if (TestProperty->IsA(UClassProperty::StaticClass()) || TestProperty->IsA(UStructProperty::StaticClass()) || CanUsePropertyType(TestProperty)) { if (RetString.Len()) { RetString.AppendChar(TEXT('\n')); } const uint8* PropData = TestProperty->ContainerPtrToValuePtr<uint8>(Ob); RetString += DescribeProperty(TestProperty, PropData); } } return RetString; }
void UK2Node_SpawnActor::CreatePinsForClass(UClass* InClass) { check(InClass != NULL); const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); for (TFieldIterator<UProperty> PropertyIt(InClass, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt) { UProperty* Property = *PropertyIt; UClass* PropertyClass = CastChecked<UClass>(Property->GetOuter()); const bool bIsDelegate = Property->IsA(UMulticastDelegateProperty::StaticClass()); const bool bIsExposedToSpawn = UEdGraphSchema_K2::IsPropertyExposedOnSpawn(Property); const bool bIsSettableExternally = !Property->HasAnyPropertyFlags(CPF_DisableEditOnInstance); if( bIsExposedToSpawn && !Property->HasAnyPropertyFlags(CPF_Parm) && bIsSettableExternally && Property->HasAllPropertyFlags(CPF_BlueprintVisible) && !bIsDelegate ) { UEdGraphPin* Pin = CreatePin(EGPD_Input, TEXT(""), TEXT(""), NULL, false, false, Property->GetName()); const bool bPinGood = (Pin != NULL) && K2Schema->ConvertPropertyToPinType(Property, /*out*/ Pin->PinType); } } // Change class of output pin UEdGraphPin* ResultPin = GetResultPin(); ResultPin->PinType.PinSubCategoryObject = InClass; }
bool FJsonObjectConverter::UStructToJsonObject(const UStruct* StructDefinition, const void* Struct, TSharedRef<FJsonObject> OutJsonObject, int64 CheckFlags, int64 SkipFlags) { for(TFieldIterator<UProperty> It(StructDefinition); It; ++It) { UProperty* Property = *It; // Check to see if we should ignore this property if (CheckFlags != 0 && !Property->HasAnyPropertyFlags(CheckFlags)) { continue; } if (Property->HasAnyPropertyFlags(SkipFlags)) { continue; } FString VariableName = StandardizeCase(Property->GetName()); const void* Value = Property->ContainerPtrToValuePtr<uint8>(Struct); // convert the property to a FJsonValue TSharedPtr<FJsonValue> JsonValue = UPropertyToJsonValue(Property, Value, CheckFlags, SkipFlags); if (!JsonValue.IsValid()) { UClass* PropClass = Property->GetClass(); UE_LOG(LogJson, Error, TEXT("UStructToJsonObject - Unhandled property type '%s': %s"), *PropClass->GetName(), *Property->GetPathName()); return false; } // set the value on the output object OutJsonObject->SetField(VariableName, JsonValue); } return true; }
void CollectBlackboardSelectors(const UObject* Ob, const UClass* StopAtClass, TArray<FName>& KeyNames) { for (UProperty* TestProperty = Ob->GetClass()->PropertyLink; TestProperty; TestProperty = TestProperty->PropertyLinkNext) { // stop when reaching base class if (TestProperty->GetOuter() == StopAtClass) { break; } // skip properties without any setup data if (TestProperty->HasAnyPropertyFlags(CPF_Transient) || TestProperty->HasAnyPropertyFlags(CPF_DisableEditOnInstance)) { continue; } const UStructProperty* StructProp = Cast<const UStructProperty>(TestProperty); if (StructProp && StructProp->GetCPPType(NULL, CPPF_None).Contains(GET_STRUCT_NAME_CHECKED(FBlackboardKeySelector))) { const FBlackboardKeySelector* PropData = TestProperty->ContainerPtrToValuePtr<FBlackboardKeySelector>(Ob); KeyNames.AddUnique(PropData->SelectedKeyName); } } }
bool FJsonObjectConverter::JsonAttributesToUStruct(const TMap< FString, TSharedPtr<FJsonValue> >& JsonAttributes, const UStruct* StructDefinition, void* OutStruct, int64 CheckFlags, int64 SkipFlags) { if (StructDefinition == FJsonObjectWrapper::StaticStruct()) { // Just copy it into the object FJsonObjectWrapper* ProxyObject = (FJsonObjectWrapper *)OutStruct; ProxyObject->JsonObject = MakeShareable(new FJsonObject()); ProxyObject->JsonObject->Values = JsonAttributes; return true; } // iterate over the struct properties for(TFieldIterator<UProperty> PropIt(StructDefinition); PropIt; ++PropIt) { UProperty* Property = *PropIt; FString PropertyName = Property->GetName(); // Check to see if we should ignore this property if (CheckFlags != 0 && !Property->HasAnyPropertyFlags(CheckFlags)) { continue; } if (Property->HasAnyPropertyFlags(SkipFlags)) { continue; } // find a json value matching this property name TSharedPtr<FJsonValue> JsonValue; for (auto It = JsonAttributes.CreateConstIterator(); It; ++It) { // use case insensitive search sincd FName may change caseing strangely on us if (PropertyName.Equals(It.Key(), ESearchCase::IgnoreCase)) { JsonValue = It.Value(); break; } } if (!JsonValue.IsValid() || JsonValue->IsNull()) { // we allow values to not be found since this mirrors the typical UObject mantra that all the fields are optional when deserializing continue; } void* Value = Property->ContainerPtrToValuePtr<uint8>(OutStruct); if (!JsonValueToUProperty(JsonValue, Property, Value, CheckFlags, SkipFlags)) { UE_LOG(LogJson, Error, TEXT("JsonObjectToUStruct - Unable to parse %s.%s from JSON"), *StructDefinition->GetName(), *PropertyName); return false; } } return true; }
bool FJsonObjectConverter::UStructToJsonAttributes(const UStruct* StructDefinition, const void* Struct, TMap< FString, TSharedPtr<FJsonValue> >& OutJsonAttributes, int64 CheckFlags, int64 SkipFlags, const CustomExportCallback* ExportCb) { if (SkipFlags == 0) { // If we have no specified skip flags, skip deprecated by default when writing SkipFlags |= CPF_Deprecated; } if (StructDefinition == FJsonObjectWrapper::StaticStruct()) { // Just copy it into the object const FJsonObjectWrapper* ProxyObject = (const FJsonObjectWrapper *)Struct; if (ProxyObject->JsonObject.IsValid()) { OutJsonAttributes = ProxyObject->JsonObject->Values; } return true; } for (TFieldIterator<UProperty> It(StructDefinition); It; ++It) { UProperty* Property = *It; // Check to see if we should ignore this property if (CheckFlags != 0 && !Property->HasAnyPropertyFlags(CheckFlags)) { continue; } if (Property->HasAnyPropertyFlags(SkipFlags)) { continue; } FString VariableName = StandardizeCase(Property->GetName()); const void* Value = Property->ContainerPtrToValuePtr<uint8>(Struct); // convert the property to a FJsonValue TSharedPtr<FJsonValue> JsonValue = UPropertyToJsonValue(Property, Value, CheckFlags, SkipFlags, ExportCb); if (!JsonValue.IsValid()) { UClass* PropClass = Property->GetClass(); UE_LOG(LogJson, Error, TEXT("UStructToJsonObject - Unhandled property type '%s': %s"), *PropClass->GetName(), *Property->GetPathName()); return false; } // set the value on the output object OutJsonAttributes.Add(VariableName, JsonValue); } return true; }
void UGatherTextFromMetaDataCommandlet::GatherTextFromUObjects(const TArray<FString>& IncludePaths, const TArray<FString>& ExcludePaths, const FGatherParameters& Arguments) { const FFuzzyPathMatcher FuzzyPathMatcher = FFuzzyPathMatcher(IncludePaths, ExcludePaths); for(TObjectIterator<UField> It; It; ++It) { // Skip editor-only properties if we're not gathering for editor-only data. UProperty* Property = Cast<UProperty>(*It); if (Property && !ShouldGatherFromEditorOnlyData && Property->HasAnyPropertyFlags(CPF_EditorOnly)) { continue; } FString SourceFilePath; FSourceCodeNavigation::FindClassHeaderPath(*It, SourceFilePath); SourceFilePath = FPaths::ConvertRelativePathToFull(SourceFilePath); check(!SourceFilePath.IsEmpty()); const FFuzzyPathMatcher::EPathMatch PathMatch = FuzzyPathMatcher.TestPath(SourceFilePath); if (PathMatch != FFuzzyPathMatcher::Included) { continue; } GatherTextFromUObject(*It, Arguments); } }
void FNodeHandlingFunctor::ResolveAndRegisterScopedTerm(FKismetFunctionContext& Context, UEdGraphPin* Net, TIndirectArray<FBPTerminal>& NetArray) { // Determine the scope this takes place in UStruct* SearchScope = Context.Function; UEdGraphPin* SelfPin = CompilerContext.GetSchema()->FindSelfPin(*(Net->GetOwningNode()), EGPD_Input); if (SelfPin != NULL) { SearchScope = Context.GetScopeFromPinType(SelfPin->PinType, Context.NewClass); } // Find the variable in the search scope UProperty* BoundProperty = FKismetCompilerUtilities::FindPropertyInScope(SearchScope, Net, CompilerContext.MessageLog, CompilerContext.GetSchema(), Context.NewClass); if (BoundProperty != NULL) { // Create the term in the list FBPTerminal* Term = new (NetArray) FBPTerminal(); Term->CopyFromPin(Net, Net->PinName); Term->AssociatedVarProperty = BoundProperty; Context.NetMap.Add(Net, Term); // Read-only variables and variables in const classes are both const if (BoundProperty->HasAnyPropertyFlags(CPF_BlueprintReadOnly) || Context.IsConstFunction()) { Term->bIsConst = true; } // Resolve the context term if (SelfPin != NULL) { FBPTerminal** pContextTerm = Context.NetMap.Find(FEdGraphUtilities::GetNetFromPin(SelfPin)); Term->Context = (pContextTerm != NULL) ? *pContextTerm : NULL; } } }
void UDeveloperSettings::ImportConsoleVariableValues() { for (UProperty* Property = GetClass()->PropertyLink; Property; Property = Property->PropertyLinkNext) { if (!Property->HasAnyPropertyFlags(CPF_Config)) { continue; } FString CVarName = Property->GetMetaData(DeveloperSettingsConsoleVariableMetaFName); if (!CVarName.IsEmpty()) { IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(*CVarName); if (CVar) { if (Property->ImportText(*CVar->GetString(), Property->ContainerPtrToValuePtr<uint8>(this, 0), PPF_ConsoleVariable, this) == NULL) { UE_LOG(LogTemp, Error, TEXT("%s import failed for %s on console variable %s (=%s)"), *GetClass()->GetName(), *Property->GetName(), *CVarName, *CVar->GetString()); } } else { UE_LOG(LogTemp, Fatal, TEXT("%s failed to find console variable %s for %s"), *GetClass()->GetName(), *CVarName, *Property->GetName()); } } } }
bool FPropertyTableColumn::CanSortBy() const { TWeakObjectPtr< UObject > Object = DataSource->AsUObject(); UProperty* Property = Cast< UProperty >( Object.Get() ); TSharedPtr< FPropertyPath > Path = DataSource->AsPropertyPath(); if ( Property == NULL && Path.IsValid() ) { Property = Path->GetLeafMostProperty().Property.Get(); } if ( Property != NULL ) { return Property->IsA( UByteProperty::StaticClass() ) || Property->IsA( UIntProperty::StaticClass() ) || Property->IsA( UBoolProperty::StaticClass() ) || Property->IsA( UFloatProperty::StaticClass() ) || Property->IsA( UNameProperty::StaticClass() ) || Property->IsA( UStrProperty::StaticClass() ) || ( Property->IsA( UObjectProperty::StaticClass() ) && !Property->HasAnyPropertyFlags(CPF_InstancedReference) ); //Property->IsA( UTextProperty::StaticClass() ); } return false; }
void AActor::ResetPropertiesForConstruction() { // Get class CDO AActor* Default = GetClass()->GetDefaultObject<AActor>(); // RandomStream struct name to compare against const FName RandomStreamName(TEXT("RandomStream")); // We don't want to reset references to world object const bool bIsLevelScriptActor = IsA(ALevelScriptActor::StaticClass()); // Iterate over properties for( TFieldIterator<UProperty> It(GetClass()) ; It ; ++It ) { UProperty* Prop = *It; UStructProperty* StructProp = Cast<UStructProperty>(Prop); UClass* PropClass = CastChecked<UClass>(Prop->GetOuter()); // get the class that added this property // First see if it is a random stream, if so reset before running construction script if( (StructProp != NULL) && (StructProp->Struct != NULL) && (StructProp->Struct->GetFName() == RandomStreamName) ) { FRandomStream* StreamPtr = StructProp->ContainerPtrToValuePtr<FRandomStream>(this); StreamPtr->Reset(); } // If it is a blueprint added variable that is not editable per-instance, reset to default before running construction script else if( !bIsLevelScriptActor && Prop->HasAnyPropertyFlags(CPF_DisableEditOnInstance) && PropClass->HasAnyClassFlags(CLASS_CompiledFromBlueprint) && !Prop->IsA(UDelegateProperty::StaticClass()) && !Prop->IsA(UMulticastDelegateProperty::StaticClass()) ) { Prop->CopyCompleteValue_InContainer(this, Default); } } }
void GetKeyablePropertyPaths(UClass* Class, UStruct* PropertySource, TArray<UProperty*>& PropertyPath, FSequencer& Sequencer, TArray<TArray<UProperty*>>& KeyablePropertyPaths) { //@todo need to resolve this between UMG and the level editor sequencer const bool bRecurseAllProperties = Sequencer.IsLevelEditorSequencer(); for (TFieldIterator<UProperty> PropertyIterator(PropertySource); PropertyIterator; ++PropertyIterator) { UProperty* Property = *PropertyIterator; if (Property && !Property->HasAnyPropertyFlags(CPF_Deprecated)) { PropertyPath.Add(Property); bool bIsPropertyKeyable = Sequencer.CanKeyProperty(FCanKeyPropertyParams(Class, PropertyPath)); if (bIsPropertyKeyable) { KeyablePropertyPaths.Add(PropertyPath); } if (!bIsPropertyKeyable || bRecurseAllProperties) { UStructProperty* StructProperty = Cast<UStructProperty>(Property); if (StructProperty != nullptr) { GetKeyablePropertyPaths(Class, StructProperty->Struct, PropertyPath, Sequencer, KeyablePropertyPaths); } } PropertyPath.RemoveAt(PropertyPath.Num() - 1); } } }
void GetInterpPropertyNames(UObject* InObject, const FString& Prefix) { UClass* ObjectClass = InObject->GetClass(); // First search for any properties in this object for (TFieldIterator<UProperty> ClassFieldIt(ObjectClass); ClassFieldIt; ++ClassFieldIt) { UProperty* ClassMemberProperty = *ClassFieldIt; if (ClassMemberProperty->HasAnyPropertyFlags(CPF_Interp)) { // Is this property the desired type? if (IsDesiredProperty(ClassMemberProperty)) { const FString QualifiedFullPath = FString::Printf(TEXT("%s%s"), *Prefix, *ClassMemberProperty->GetName()); GatheredPropertyPaths.Add(*QualifiedFullPath); } // If this is a struct, look for any desired properties inside of it if (UStructProperty* OuterStructProperty = Cast<UStructProperty>(ClassMemberProperty)) { for (TFieldIterator<UProperty> StructFieldIt(OuterStructProperty->Struct); StructFieldIt; ++StructFieldIt) { UProperty* StructMemberProperty = *StructFieldIt; if (StructMemberProperty->HasAnyPropertyFlags(CPF_Interp) && IsDesiredProperty(StructMemberProperty)) { const FString QualifiedFullPath = FString::Printf(TEXT("%s%s.%s"), *Prefix, *OuterStructProperty->GetName(), *StructMemberProperty->GetName()); GatheredPropertyPaths.Add(*QualifiedFullPath); } } } } } // Then iterate over each subobject of this object looking for interp properties. TArray<UObject*> DefaultSubObjects; ObjectClass->GetDefaultObjectSubobjects(DefaultSubObjects); for (int32 SubObjectIndex = 0; SubObjectIndex < DefaultSubObjects.Num(); ++SubObjectIndex) { UObject* Component = DefaultSubObjects[SubObjectIndex]; const FString ComponentPrefix = Component->GetName() + TEXT("."); GetInterpPropertyNames(Component, ComponentPrefix); } }
void UGatherTextFromMetaDataCommandlet::GatherTextFromUObjects(const TArray<FString>& IncludePaths, const TArray<FString>& ExcludePaths, const FGatherParameters& Arguments) { for(TObjectIterator<UField> It; It; ++It) { // Skip editor-only properties if we're not gathering for editor-only data. UProperty* Property = Cast<UProperty>(*It); if (Property && !ShouldGatherFromEditorOnlyData && Property->HasAnyPropertyFlags(CPF_EditorOnly)) { continue; } FString SourceFilePath; FSourceCodeNavigation::FindClassHeaderPath(*It, SourceFilePath); SourceFilePath = FPaths::ConvertRelativePathToFull(SourceFilePath); check(!SourceFilePath.IsEmpty()); // Returns true if in an include path. False otherwise. auto IncludePathLogic = [&]() -> bool { for(int32 i = 0; i < IncludePaths.Num(); ++i) { if(SourceFilePath.MatchesWildcard(IncludePaths[i])) { return true; } } return false; }; if(!IncludePathLogic()) { continue; } // Returns true if in an exclude path. False otherwise. auto ExcludePathLogic = [&]() -> bool { for(int32 i = 0; i < ExcludePaths.Num(); ++i) { if(SourceFilePath.MatchesWildcard(ExcludePaths[i])) { return true; } } return false; }; if(ExcludePathLogic()) { continue; } GatherTextFromUObject(*It, Arguments); } }
void Construct(int32 index) { if (ElementProperty->HasAnyPropertyFlags(CPF_ZeroConstructor)) { FMemory::Memzero(GetRawPtr(index), ElementSize); } else { ElementProperty->InitializeValue(GetRawPtr(index)); } }
bool UK2Node_CallDelegate::CreatePinsForFunctionInputs(const UFunction* Function) { const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); // Create the inputs and outputs bool bAllPinsGood = true; for (TFieldIterator<UProperty> PropIt(Function); PropIt && (PropIt->PropertyFlags & CPF_Parm); ++PropIt) { UProperty* Param = *PropIt; const bool bIsFunctionInput = !Param->HasAnyPropertyFlags(CPF_OutParm) || Param->HasAnyPropertyFlags(CPF_ReferenceParm); if (bIsFunctionInput) { UEdGraphPin* Pin = CreatePin(EGPD_Input, TEXT(""), TEXT(""), NULL, false, false, Param->GetName()); const bool bPinGood = K2Schema->ConvertPropertyToPinType(Param, /*out*/ Pin->PinType); bAllPinsGood = bAllPinsGood && bPinGood; } } return bAllPinsGood; }
void FStructurePropertyNode::InitChildNodes() { const bool bShouldShowHiddenProperties = !!HasNodeFlags(EPropertyNodeFlags::ShouldShowHiddenProperties); const bool bShouldShowDisableEditOnInstance = !!HasNodeFlags(EPropertyNodeFlags::ShouldShowDisableEditOnInstance); const UStruct* Struct = StructData.IsValid() ? StructData->GetStruct() : NULL; for (TFieldIterator<UProperty> It(Struct); It; ++It) { UProperty* StructMember = *It; if (StructMember) { static const FName Name_InlineEditConditionToggle("InlineEditConditionToggle"); const bool bOnlyShowAsInlineEditCondition = StructMember->HasMetaData(Name_InlineEditConditionToggle); const bool bShowIfEditableProperty = StructMember->HasAnyPropertyFlags(CPF_Edit); const bool bShowIfDisableEditOnInstance = !StructMember->HasAnyPropertyFlags(CPF_DisableEditOnInstance) || bShouldShowDisableEditOnInstance; if (bShouldShowHiddenProperties || (bShowIfEditableProperty && !bOnlyShowAsInlineEditCondition && bShowIfDisableEditOnInstance)) { TSharedPtr<FItemPropertyNode> NewItemNode(new FItemPropertyNode);//;//CreatePropertyItem(StructMember,INDEX_NONE,this); FPropertyNodeInitParams InitParams; InitParams.ParentNode = SharedThis(this); InitParams.Property = StructMember; InitParams.ArrayOffset = 0; InitParams.ArrayIndex = INDEX_NONE; InitParams.bAllowChildren = true; InitParams.bForceHiddenPropertyVisibility = bShouldShowHiddenProperties; InitParams.bCreateDisableEditOnInstanceNodes = bShouldShowDisableEditOnInstance; InitParams.bCreateCategoryNodes = false; NewItemNode->InitNode(InitParams); AddChildNode(NewItemNode); } } } }
void USpeedTreeImportData::SaveOptions() { int32 PortFlags = 0; for (UProperty* Property = GetClass()->PropertyLink; Property; Property = Property->PropertyLinkNext) { if (!Property->HasAnyPropertyFlags(CPF_Config)) { continue; } FString Section = TEXT("SpeedTree_Import_UI_Option_") + GetClass()->GetName(); FString Key = Property->GetName(); const bool bIsPropertyInherited = Property->GetOwnerClass() != GetClass(); UObject* SuperClassDefaultObject = GetClass()->GetSuperClass()->GetDefaultObject(); UArrayProperty* Array = dynamic_cast<UArrayProperty*>(Property); if (Array) { FConfigSection* Sec = GConfig->GetSectionPrivate(*Section, 1, 0, *GEditorPerProjectIni); check(Sec); Sec->Remove(*Key); FScriptArrayHelper_InContainer ArrayHelper(Array, this); for (int32 i = 0; i < ArrayHelper.Num(); i++) { FString Buffer; Array->Inner->ExportTextItem(Buffer, ArrayHelper.GetRawPtr(i), ArrayHelper.GetRawPtr(i), this, PortFlags); Sec->Add(*Key, *Buffer); } } else { TCHAR TempKey[MAX_SPRINTF] = TEXT(""); for (int32 Index = 0; Index < Property->ArrayDim; Index++) { if (Property->ArrayDim != 1) { FCString::Sprintf(TempKey, TEXT("%s[%i]"), *Property->GetName(), Index); Key = TempKey; } FString Value; Property->ExportText_InContainer(Index, Value, this, this, this, PortFlags); GConfig->SetString(*Section, *Key, *Value, *GEditorPerProjectIni); } } } GConfig->Flush(0); }
void GetMaterialBrushPropertyPathsRecursive(void* DataObject, UStruct* PropertySource, TArray<UProperty*>& PropertyPath, TArray<TArray<UProperty*>>& MaterialBrushPropertyPaths ) { if ( DataObject != nullptr ) { for ( TFieldIterator<UProperty> PropertyIterator( PropertySource ); PropertyIterator; ++PropertyIterator ) { UProperty* Property = *PropertyIterator; if ( Property != nullptr && Property->HasAnyPropertyFlags( CPF_Deprecated ) == false ) { PropertyPath.Add( Property ); UStructProperty* StructProperty = Cast<UStructProperty>( Property ); if ( StructProperty != nullptr ) { const FName StructName = StructProperty->Struct->GetFName(); void* Data = Property->ContainerPtrToValuePtr<void>(DataObject); UMaterialInterface* MaterialInterface = nullptr; if(StructName == TMaterialStructType<FSlateFontInfo>::GetTypeName()) { MaterialInterface = TMaterialStructType<FSlateFontInfo>::GetMaterial(Data); } else if(StructName == TMaterialStructType<FSlateBrush>::GetTypeName()) { MaterialInterface =TMaterialStructType<FSlateBrush>::GetMaterial(Data); } else if(StructName == TMaterialStructType<FFontOutlineSettings>::GetTypeName()) { MaterialInterface =TMaterialStructType<FFontOutlineSettings>::GetMaterial(Data); } if(MaterialInterface) { MaterialBrushPropertyPaths.Add(PropertyPath); } else { GetMaterialBrushPropertyPathsRecursive( StructProperty->ContainerPtrToValuePtr<void>( DataObject ), StructProperty->Struct, PropertyPath, MaterialBrushPropertyPaths ); } } PropertyPath.RemoveAt( PropertyPath.Num() - 1 ); } } } }
TSharedRef<SWidget> FDetailWidgetExtensionHandler::GenerateExtensionWidget(const UClass* InObjectClass, TSharedPtr<IPropertyHandle> InPropertyHandle) { UProperty* Property = InPropertyHandle->GetProperty(); FString DelegateName = Property->GetName() + "Delegate"; UDelegateProperty* DelegateProperty = FindFieldChecked<UDelegateProperty>(CastChecked<UClass>(Property->GetOuter()), FName(*DelegateName)); const bool bIsEditable = Property->HasAnyPropertyFlags(CPF_Edit | CPF_EditConst); const bool bDoSignaturesMatch = DelegateProperty->SignatureFunction->GetReturnProperty()->SameType(Property); if ( !ensure(bIsEditable && bDoSignaturesMatch) ) { return SNullWidget::NullWidget; } return SNew(SPropertyBinding, BlueprintEditor.Pin().ToSharedRef(), DelegateProperty, InPropertyHandle.ToSharedRef()) .GeneratePureBindings(true); }
void FAIDataProviderValue::GetMatchingProperties(TArray<FName>& MatchingProperties) const { if (DataBinding) { for (UProperty* Prop = DataBinding->GetClass()->PropertyLink; Prop; Prop = Prop->PropertyLinkNext) { if (Prop->HasAnyPropertyFlags(CPF_Edit)) { continue; } if (IsMatchingType(Prop)) { MatchingProperties.Add(Prop->GetFName()); } } } }
bool SGraphPinLiveEditVar::IsPropertyPermitedForLiveEditor( UProperty &Property ) { const bool bIsDelegate = Property.IsA(UMulticastDelegateProperty::StaticClass()); //YES (must have all) uint64 MustHaveFlags = CPF_Edit; //NO (must not have any) uint64 MustNotHaveFlags = CPF_BlueprintReadOnly | CPF_DisableEditOnInstance | CPF_EditConst | CPF_Parm; if ( !Property.HasAllPropertyFlags(MustHaveFlags) ) return false; if ( Property.HasAnyPropertyFlags(MustNotHaveFlags) ) return false; if ( bIsDelegate ) return false; return true; }
void FindReferences(UObject* Object) { UProperty* Property = Cast<UProperty>(Object); if (Property && Property->HasAnyPropertyFlags(CPF_DevelopmentAssets)) { return; } { FSimpleObjectReferenceCollectorArchive CollectorArchive(Object, *this); CollectorArchive.SetSerializedProperty(nullptr); CollectorArchive.SetFilterEditorOnly(true); if (UClass* AsBPGC = Cast<UBlueprintGeneratedClass>(Object)) { Object = Dependencies.FindOriginalClass(AsBPGC); } Object->Serialize(CollectorArchive); } }
void RegisterOutputTerm(FKismetFunctionContext& Context, UScriptStruct* StructType, UEdGraphPin* Net, FBPTerminal* ContextTerm) { UProperty* BoundProperty = FindField<UProperty>(StructType, *(Net->PinName)); if (BoundProperty != NULL) { FBPTerminal* Term = new (Context.IsEventGraph() ? Context.EventGraphLocals : Context.Locals) FBPTerminal(); Term->CopyFromPin(Net, Net->PinName); Term->AssociatedVarProperty = BoundProperty; Context.NetMap.Add(Net, Term); Term->Context = ContextTerm; if (BoundProperty->HasAnyPropertyFlags(CPF_BlueprintReadOnly)) { Term->bIsConst = true; } } else { CompilerContext.MessageLog.Error(TEXT("Failed to find a struct member for @@"), Net); } }
FString SGraphNodeK2CreateDelegate::FunctionDescription(const UFunction* Function) { if(!Function || !Function->GetOuter()) { return NSLOCTEXT("GraphNodeK2Create", "Error", "Error").ToString(); } const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); //FString Result = Function->GetOuter()->GetName() + TEXT("::") + Function->GetName(); //Result += TEXT("("); FString Result = Function->GetName() + TEXT("("); bool bFirst = true; for (TFieldIterator<UProperty> PropIt(Function); PropIt && (PropIt->PropertyFlags & CPF_Parm); ++PropIt) { UProperty* Param = *PropIt; const bool bIsFunctionInput = Param && (!Param->HasAnyPropertyFlags(CPF_OutParm) || Param->HasAnyPropertyFlags(CPF_ReferenceParm)); if(bIsFunctionInput) { if(!bFirst) { Result += TEXT(", "); } if(Result.Len() > 32) { Result += TEXT("..."); break; } Result += Param->GetName(); bFirst = false; } } Result += TEXT(")"); return Result; }
void UK2Node_LatentAbilityCall::CreatePinsForClass(UClass* InClass) { check(InClass != NULL); const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); const UObject* const ClassDefaultObject = InClass->GetDefaultObject(false); SpawnParmPins.Empty(); // Tasks can hide spawn parameters by doing meta = (HideSpawnParms="PropertyA,PropertyB") // (For example, hide Instigator in situations where instigator is not relevant to your task) TArray<FString> IgnorePropertyList; { UFunction* ProxyFunction = ProxyFactoryClass->FindFunctionByName(ProxyFactoryFunctionName); FString IgnorePropertyListStr = ProxyFunction->GetMetaData(FName(TEXT("HideSpawnParms"))); if (!IgnorePropertyListStr.IsEmpty()) { IgnorePropertyListStr.ParseIntoArray(IgnorePropertyList, TEXT(","), true); } } for (TFieldIterator<UProperty> PropertyIt(InClass, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt) { UProperty* Property = *PropertyIt; UClass* PropertyClass = CastChecked<UClass>(Property->GetOuter()); const bool bIsDelegate = Property->IsA(UMulticastDelegateProperty::StaticClass()); const bool bIsExposedToSpawn = UEdGraphSchema_K2::IsPropertyExposedOnSpawn(Property); const bool bIsSettableExternally = !Property->HasAnyPropertyFlags(CPF_DisableEditOnInstance); if (bIsExposedToSpawn && !Property->HasAnyPropertyFlags(CPF_Parm) && bIsSettableExternally && Property->HasAllPropertyFlags(CPF_BlueprintVisible) && !bIsDelegate && !IgnorePropertyList.Contains(Property->GetName()) && (FindPin(Property->GetName()) == nullptr) ) { UEdGraphPin* Pin = CreatePin(EGPD_Input, TEXT(""), TEXT(""), NULL, false, false, Property->GetName()); const bool bPinGood = (Pin != NULL) && K2Schema->ConvertPropertyToPinType(Property, /*out*/ Pin->PinType); SpawnParmPins.Add(Pin); if (ClassDefaultObject && Pin && K2Schema->PinDefaultValueIsEditable(*Pin)) { FString DefaultValueAsString; const bool bDefaultValueSet = FBlueprintEditorUtils::PropertyValueToString(Property, reinterpret_cast<const uint8*>(ClassDefaultObject), DefaultValueAsString); check(bDefaultValueSet); K2Schema->TrySetDefaultValue(*Pin, DefaultValueAsString); } // Copy tooltip from the property. if (Pin != nullptr) { K2Schema->ConstructBasicPinTooltip(*Pin, Property->GetToolTipText(), Pin->PinToolTip); } } } }