本文整理汇总了C++中UProperty::IsA方法的典型用法代码示例。如果您正苦于以下问题:C++ UProperty::IsA方法的具体用法?C++ UProperty::IsA怎么用?C++ UProperty::IsA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UProperty
的用法示例。
在下文中一共展示了UProperty::IsA方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CollectPropertyDescription
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;
}
示例2: DiffProperties
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);
}
}
}
}
示例3: CanExportFunction
bool FScriptCodeGeneratorBase::CanExportFunction(const FString& ClassNameCPP, UClass* Class, UFunction* Function)
{
// We don't support delegates and non-public functions
if ((Function->FunctionFlags & FUNC_Delegate))
{
return false;
}
// Reject if any of the parameter types is unsupported yet
for (TFieldIterator<UProperty> ParamIt(Function); ParamIt; ++ParamIt)
{
UProperty* Param = *ParamIt;
if (Param->IsA(UArrayProperty::StaticClass()) ||
Param->ArrayDim > 1 ||
Param->IsA(UDelegateProperty::StaticClass()) ||
Param->IsA(UMulticastDelegateProperty::StaticClass()) ||
Param->IsA(UWeakObjectProperty::StaticClass()) ||
Param->IsA(UInterfaceProperty::StaticClass()))
{
return false;
}
}
return true;
}
示例4: ResetPropertiesForConstruction
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);
}
}
}
示例5: SetCellValue
void SetCellValue( const TSharedRef< IPropertyTableCell >& Cell, FString Value )
{
if ( Cell->IsReadOnly() )
{
return;
}
// We need to sanitize property name strings
TSharedPtr<FPropertyNode> PropertyNode = Cell->GetNode();
if (PropertyNode.IsValid())
{
UProperty* NodeProperty = PropertyNode->GetProperty();
if (NodeProperty->IsA(UNameProperty::StaticClass()))
{
// Remove any pre-existing return characters
Value = Value.TrimQuotes().Replace(TEXT("\n"), TEXT(""));
}
}
FString CurrentValue = Cell->GetValueAsString();
if ( CurrentValue != Value )
{
// Set value
Cell->SetValueFromString( Value );
}
}
示例6: CreatePin
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;
}
示例7: FindNotifyPropertyData
uint8* UAnimSequenceBase::FindNotifyPropertyData(int32 NotifyIndex, UArrayProperty*& ArrayProperty)
{
// initialize to NULL
ArrayProperty = NULL;
if(Notifies.IsValidIndex(NotifyIndex))
{
// find Notifies property start point
UProperty* Property = FindField<UProperty>(GetClass(), TEXT("Notifies"));
// found it and if it is array
if(Property && Property->IsA(UArrayProperty::StaticClass()))
{
// find Property Value from UObject we got
uint8* PropertyValue = Property->ContainerPtrToValuePtr<uint8>(this);
// it is array, so now get ArrayHelper and find the raw ptr of the data
ArrayProperty = CastChecked<UArrayProperty>(Property);
FScriptArrayHelper ArrayHelper(ArrayProperty, PropertyValue);
if(ArrayProperty->Inner && NotifyIndex < ArrayHelper.Num())
{
//Get property data based on selected index
return ArrayHelper.GetRawPtr(NotifyIndex);
}
}
}
return NULL;
}
示例8: SendToObjects
void SPropertyEditorCombo::SendToObjects( const FString& NewValue )
{
const TSharedRef< FPropertyNode > PropertyNode = PropertyEditor->GetPropertyNode();
UProperty* Property = PropertyNode->GetProperty();
FString Value;
if ( bUsesAlternateDisplayValues && !Property->IsA(UStrProperty::StaticClass()))
{
// currently only enum properties can use alternate display values; this
// might change, so assert here so that if support is expanded to other
// property types without updating this block of code, we'll catch it quickly
UEnum* Enum = CastChecked<UByteProperty>(Property)->Enum;
check(Enum != nullptr);
const int32 Index = FindEnumValueIndex(Enum, NewValue);
check( Index != INDEX_NONE );
Value = Enum->GetEnumName(Index);
FText ToolTipValue = Enum->GetToolTipText(Index);
FText ToolTipText = Property->GetToolTipText();
if (!ToolTipValue.IsEmpty())
{
ToolTipText = FText::Format(FText::FromString(TEXT("{0}\n\n{1}")), ToolTipText, ToolTipValue);
}
SetToolTipText(ToolTipText);
}
else
{
Value = NewValue;
}
const TSharedRef< IPropertyHandle > PropertyHandle = PropertyEditor->GetPropertyHandle();
PropertyHandle->SetValueFromFormattedString( Value );
}
示例9: AddClassPropertyActions
//------------------------------------------------------------------------------
static void BlueprintActionDatabaseImpl::AddClassPropertyActions(UClass const* const Class, FActionList& ActionListOut)
{
using namespace FBlueprintNodeSpawnerFactory; // for MakeDelegateNodeSpawner()
bool const bIsComponent = Class->IsChildOf<UActorComponent>();
bool const bIsActorClass = Class->IsChildOf<AActor>();
// loop over all the properties in the specified class; exclude-super because
// we can always get the super properties by looking up that class separateHavely
for (TFieldIterator<UProperty> PropertyIt(Class, EFieldIteratorFlags::ExcludeSuper); PropertyIt; ++PropertyIt)
{
UProperty* Property = *PropertyIt;
if (!IsPropertyBlueprintVisible(Property))
{
continue;
}
bool const bIsDelegate = Property->IsA(UMulticastDelegateProperty::StaticClass());
if (bIsDelegate)
{
UMulticastDelegateProperty* DelegateProperty = CastChecked<UMulticastDelegateProperty>(Property);
if (DelegateProperty->HasAnyPropertyFlags(CPF_BlueprintAssignable))
{
UBlueprintNodeSpawner* AddSpawner = UBlueprintDelegateNodeSpawner::Create(UK2Node_AddDelegate::StaticClass(), DelegateProperty);
ActionListOut.Add(AddSpawner);
UBlueprintNodeSpawner* AssignSpawner = MakeAssignDelegateNodeSpawner(DelegateProperty);
ActionListOut.Add(AssignSpawner);
}
if (DelegateProperty->HasAnyPropertyFlags(CPF_BlueprintCallable))
{
UBlueprintNodeSpawner* CallSpawner = UBlueprintDelegateNodeSpawner::Create(UK2Node_CallDelegate::StaticClass(), DelegateProperty);
ActionListOut.Add(CallSpawner);
}
UBlueprintNodeSpawner* RemoveSpawner = UBlueprintDelegateNodeSpawner::Create(UK2Node_RemoveDelegate::StaticClass(), DelegateProperty);
ActionListOut.Add(RemoveSpawner);
UBlueprintNodeSpawner* ClearSpawner = UBlueprintDelegateNodeSpawner::Create(UK2Node_ClearDelegate::StaticClass(), DelegateProperty);
ActionListOut.Add(ClearSpawner);
if (bIsComponent)
{
ActionListOut.Add(MakeComponentBoundEventSpawner(DelegateProperty));
}
else if (bIsActorClass)
{
ActionListOut.Add(MakeActorBoundEventSpawner(DelegateProperty));
}
}
else
{
UBlueprintVariableNodeSpawner* GetterSpawner = UBlueprintVariableNodeSpawner::Create(UK2Node_VariableGet::StaticClass(), Property);
ActionListOut.Add(GetterSpawner);
UBlueprintVariableNodeSpawner* SetterSpawner = UBlueprintVariableNodeSpawner::Create(UK2Node_VariableSet::StaticClass(), Property);
ActionListOut.Add(SetterSpawner);
}
}
}
示例10: CanSortBy
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;
}
示例11: GenerateFunctionWrapper
void FCSharpWrapperGenerator::GenerateFunctionWrapper(const UFunction* Function)
{
FString formalInteropArgs, actualInteropArgs, formalManagedArgs, actualManagedArgs;
UProperty* returnValue = GetWrapperArgsAndReturnType(
Function, formalInteropArgs, actualInteropArgs, formalManagedArgs, actualManagedArgs
);
const bool bHasReturnValue = (returnValue != nullptr);
const bool bReturnsBool = (bHasReturnValue && returnValue->IsA(UBoolProperty::StaticClass()));
const FString returnValueInteropTypeName =
bHasReturnValue ? GetPropertyInteropType(returnValue) : TEXT("void");
const FString returnValueManagedTypeName =
bHasReturnValue ? GetPropertyManagedType(returnValue) : TEXT("void");
const FString delegateTypeName = GetDelegateTypeName(Function->GetName(), bHasReturnValue);
const FString delegateName = GetDelegateName(Function->GetName());
GeneratedGlue
// declare a managed delegate type matching the type of the native wrapper function
<< UnmanagedFunctionPointerAttribute
<< (bReturnsBool ? MarshalReturnedBoolAsUint8Attribute : FString())
<< FString::Printf(
TEXT("private delegate %s %s(%s);"),
*returnValueInteropTypeName, *delegateTypeName, *formalInteropArgs
)
// declare a delegate instance that will be bound to the native wrapper function
<< FString::Printf(
TEXT("private static %s %s;"),
*delegateTypeName, *delegateName
)
// define a managed method that calls the native wrapper function through the delegate
// declared above
<< FString::Printf(
TEXT("public %s %s(%s)"),
*returnValueManagedTypeName, *Function->GetName(), *formalManagedArgs
)
<< FCodeFormatter::OpenBrace();
// call the delegate bound to the native wrapper function
if (bHasReturnValue)
{
GeneratedGlue
<< FString::Printf(TEXT("var value = %s(%s);"), *delegateName, *actualInteropArgs)
<< GetReturnValueHandler(returnValue);
}
else
{
GeneratedGlue << FString::Printf(TEXT("%s(%s);"), *delegateName, *actualInteropArgs);
}
GeneratedGlue
<< FCodeFormatter::CloseBrace()
<< FCodeFormatter::LineTerminator();
FExportedFunction funcInfo;
funcInfo.DelegateName = delegateName;
funcInfo.DelegateTypeName = delegateTypeName;
ExportedFunctions.Add(funcInfo);
}
示例12: GetTemplateFromNode
void UK2Node_AddComponent::AllocatePinsForExposedVariables()
{
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
const UActorComponent* TemplateComponent = GetTemplateFromNode();
const UClass* ComponentClass = TemplateComponent ? TemplateComponent->GetClass() : nullptr;
if (ComponentClass != nullptr)
{
const UObject* ClassDefaultObject = ComponentClass ? ComponentClass->ClassDefaultObject : nullptr;
for (TFieldIterator<UProperty> PropertyIt(ComponentClass, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt)
{
UProperty* Property = *PropertyIt;
const bool bNotDelegate = !Property->IsA(UMulticastDelegateProperty::StaticClass());
const bool bIsExposedToSpawn = UEdGraphSchema_K2::IsPropertyExposedOnSpawn(Property);
const bool bIsVisible = Property->HasAllPropertyFlags(CPF_BlueprintVisible);
const bool bNotParam = !Property->HasAllPropertyFlags(CPF_Parm);
if(bNotDelegate && bIsExposedToSpawn && bIsVisible && bNotParam)
{
FEdGraphPinType PinType;
K2Schema->ConvertPropertyToPinType(Property, /*out*/ PinType);
const bool bIsUnique = (NULL == FindPin(Property->GetName()));
if (K2Schema->FindSetVariableByNameFunction(PinType) && bIsUnique)
{
UEdGraphPin* Pin = CreatePin(EGPD_Input, TEXT(""), TEXT(""), NULL, false, false, Property->GetName());
Pin->PinType = PinType;
bHasExposedVariable = true;
if ((ClassDefaultObject != nullptr) && 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.
K2Schema->ConstructBasicPinTooltip(*Pin, Property->GetToolTipText(), Pin->PinToolTip);
}
}
}
}
// Hide transform and attachment pins if it is not a scene component
const bool bHideTransformPins = (ComponentClass != nullptr) ? !ComponentClass->IsChildOf(USceneComponent::StaticClass()) : false;
UEdGraphPin* ManualAttachmentPin = GetManualAttachmentPin();
ManualAttachmentPin->SafeSetHidden(bHideTransformPins);
UEdGraphPin* TransformPin = GetRelativeTransformPin();
TransformPin->SafeSetHidden(bHideTransformPins);
}
示例13: SendToObjects
void SPropertyEditorCombo::SendToObjects( const FString& NewValue )
{
const TSharedRef< FPropertyNode > PropertyNode = PropertyEditor->GetPropertyNode();
UProperty* Property = PropertyNode->GetProperty();
FString Value;
FString ToolTipValue;
if ( bUsesAlternateDisplayValues && !Property->IsA(UStrProperty::StaticClass()))
{
// currently only enum properties can use alternate display values; this might change, so assert here so that if support is expanded to other property types
// without updating this block of code, we'll catch it quickly
UEnum* Enum = CastChecked<UByteProperty>(Property)->Enum;
check(Enum);
int32 Index = INDEX_NONE;
for( int32 ItemIndex = 0; ItemIndex < Enum->NumEnums(); ++ItemIndex )
{
const FString EnumName = Enum->GetEnumName(ItemIndex);
const FString DisplayName = Enum->GetDisplayNameText(ItemIndex ).ToString();
if( DisplayName.Len() > 0 )
{
if ( DisplayName == NewValue )
{
Index = ItemIndex;
break;
}
}
else if (EnumName == NewValue)
{
Index = ItemIndex;
break;
}
}
check( Index != INDEX_NONE );
Value = Enum->GetEnumName(Index);
ToolTipValue = Enum->GetMetaData( TEXT("ToolTip"), Index );
FString ToolTipText = Property->GetToolTipText().ToString();
if (ToolTipValue.Len() > 0)
{
ToolTipText = FString::Printf(TEXT("%s\n\n%s"), *ToolTipText, *ToolTipValue);
}
SetToolTipText(ToolTipText);
}
else
{
Value = NewValue;
}
const TSharedRef< IPropertyHandle > PropertyHandle = PropertyEditor->GetPropertyHandle();
PropertyHandle->SetValueFromFormattedString( Value );
}
示例14: CanEnableMultiLineText
bool FStructureEditorUtils::CanEnableMultiLineText(const UUserDefinedStruct* Struct, FGuid VarGuid)
{
auto VarDesc = GetVarDescByGuid(Struct, VarGuid);
if (VarDesc)
{
UProperty* Property = FindField<UProperty>(Struct, VarDesc->VarName);
// If this is an array, we need to test its inner property as that's the real type
if (UArrayProperty* ArrayProperty = Cast<UArrayProperty>(Property))
{
Property = ArrayProperty->Inner;
}
if (Property)
{
// Can only set multi-line text on string and text properties
return Property->IsA(UStrProperty::StaticClass())
|| Property->IsA(UTextProperty::StaticClass());
}
}
return false;
}
示例15: ReplicateChangesToChildren
void ULiveEditorKismetLibrary::ReplicateChangesToChildren( FName PropertyName, UObject *Archetype )
{
if ( Archetype == NULL )
return;
//find our child instances from the LiveEditManage lookup cache
TArray< TWeakObjectPtr<UObject> > PiePartners;
FLiveEditorManager::Get().FindPiePartners( Archetype, PiePartners );
for(TArray< TWeakObjectPtr<UObject> >::TIterator It(PiePartners); It; ++It)
{
if ( !(*It).IsValid() )
continue;
UObject *Object = (*It).Get();
check( Object->IsA(Archetype->GetClass()) ); //little sanity check, but the object cache manages all this for us
nLiveEditorKismetLibrary::CopyPropertyFromArchetype( Object, Archetype, PropertyName );
}
void *ContainerPtr = Archetype;
int32 ArrayIndex = 0;
UProperty *Prop = nLiveEditorKismetLibrary::GetPropertyByName( Archetype, Archetype->GetClass(), PropertyName.ToString(), &ContainerPtr, ArrayIndex );
if ( Prop && Prop->IsA( UNumericProperty::StaticClass() ) )
{
check( ContainerPtr != NULL );
FString ClassName = Archetype->GetClass()->GetName();
FString ValueString;
void *Value = Prop->ContainerPtrToValuePtr<void>(ContainerPtr, ArrayIndex);
Prop->ExportTextItem(ValueString, Value, NULL, NULL, 0);
FLiveEditorManager::Get().BroadcastValueUpdate( ClassName, PropertyName.ToString(), ValueString );
}
/**
* Object iteration method should we want to dump the PIEObjectCache
* Downside is that it is perceptably slow (though still usable)
TArray<UObject*> ObjectsToChange;
const bool bIncludeDerivedClasses = true;
GetObjectsOfClass(Archetype->GetClass(), ObjectsToChange, bIncludeDerivedClasses);
for ( auto ObjIt = ObjectsToChange.CreateIterator(); ObjIt; ++ObjIt )
{
UObject *Object = *ObjIt;
UWorld *World = GEngine->GetWorldFromContextObject( Object, false );
if ( World == NULL || World->WorldType != EWorldType::PIE )
continue;
CopyPropertyFromArchetype( Object, Archetype, PropertyName );
}
*/
}