本文整理汇总了C++中UProperty::ImportText方法的典型用法代码示例。如果您正苦于以下问题:C++ UProperty::ImportText方法的具体用法?C++ UProperty::ImportText怎么用?C++ UProperty::ImportText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UProperty
的用法示例。
在下文中一共展示了UProperty::ImportText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportConsoleVariableValues
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());
}
}
}
}
示例2: ApplyCustomFactorySetting
/**
* Applies settings to an object by finding UProperties by name and calling ImportText
*
* @param InObject - The object to search for matching properties
* @param PropertyChain - The list UProperty names recursively to search through
* @param Value - The value to import on the found property
*/
void ApplyCustomFactorySetting(UObject* InObject, TArray<FString>& PropertyChain, const FString& Value)
{
const FString PropertyName = PropertyChain[0];
PropertyChain.RemoveAt(0);
UProperty* TargetProperty = FindField<UProperty>(InObject->GetClass(), *PropertyName);
if (TargetProperty)
{
if (PropertyChain.Num() == 0)
{
TargetProperty->ImportText(*Value, TargetProperty->ContainerPtrToValuePtr<uint8>(InObject), 0, InObject);
}
else
{
UStructProperty* StructProperty = Cast<UStructProperty>(TargetProperty);
UObjectProperty* ObjectProperty = Cast<UObjectProperty>(TargetProperty);
UObject* SubObject = NULL;
bool bValidPropertyType = true;
if (StructProperty)
{
SubObject = StructProperty->Struct;
}
else if (ObjectProperty)
{
SubObject = ObjectProperty->GetObjectPropertyValue(ObjectProperty->ContainerPtrToValuePtr<UObject>(InObject));
}
else
{
//Unknown nested object type
bValidPropertyType = false;
UE_LOG(LogAutomationEditorCommon, Error, TEXT("ERROR: Unknown nested object type for property: %s"), *PropertyName);
}
if (SubObject)
{
ApplyCustomFactorySetting(SubObject, PropertyChain, Value);
}
else if (bValidPropertyType)
{
UE_LOG(LogAutomationEditorCommon, Error, TEXT("Error accessing null property: %s"), *PropertyName);
}
}
}
else
{
UE_LOG(LogAutomationEditorCommon, Error, TEXT("ERROR: Could not find factory property: %s"), *PropertyName);
}
}
示例3: SetPropertyByName
/**
* Sets an object property value by name
* @param TargetObject - The object to modify
* @param InVariableName - The name of the property
*/
void SetPropertyByName(UObject* TargetObject, const FString& InVariableName, const FString& NewValueString)
{
UProperty* FoundProperty = FindField<UProperty>(TargetObject->GetClass(), *InVariableName);
if (FoundProperty)
{
const FScopedTransaction PropertyChanged(LOCTEXT("PropertyChanged", "Object Property Change"));
TargetObject->Modify();
TargetObject->PreEditChange(FoundProperty);
FoundProperty->ImportText(*NewValueString, FoundProperty->ContainerPtrToValuePtr<uint8>(TargetObject), 0, TargetObject);
FPropertyChangedEvent PropertyChangedEvent(FoundProperty, EPropertyChangeType::ValueSet);
TargetObject->PostEditChangeProperty(PropertyChangedEvent);
}
}
示例4: if
UMaterial* T3DMaterialParser::ImportMaterial()
{
FString ClassName, Name, Value;
UClass * Class;
ensure(NextLine());
ensure(IsBeginObject(ClassName));
ensure(ClassName == TEXT("Material"));
ensure(GetOneValueAfter(TEXT(" Name="), Name));
FString BasePackageName = FString::Printf(TEXT("/Game/UDK/%s/Materials"), *Package);
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools");
UMaterialFactoryNew* MaterialFactory = ConstructObject<UMaterialFactoryNew>(UMaterialFactoryNew::StaticClass());
Material = (UMaterial*)AssetToolsModule.Get().CreateAsset(Name, BasePackageName, UMaterial::StaticClass(), MaterialFactory);
if (Material == NULL)
{
return NULL;
}
Material->Modify();
while (NextLine() && !IsEndObject())
{
if (IsBeginObject(ClassName))
{
if (ClassName == TEXT("MaterialExpressionFlipBookSample"))
{
Class = UMaterialExpressionTextureSample::StaticClass();
}
else
{
Class = (UClass*)StaticFindObject(UClass::StaticClass(), ANY_PACKAGE, *ClassName, true);
}
if (Class)
{
ensure(GetOneValueAfter(TEXT(" Name="), Name));
FRequirement TextureRequirement;
UMaterialExpression* MaterialExpression = ImportMaterialExpression(Class, TextureRequirement);
UMaterialExpressionComment * MaterialExpressionComment = Cast<UMaterialExpressionComment>(MaterialExpression);
if (MaterialExpressionComment)
{
Material->EditorComments.Add(MaterialExpressionComment);
MaterialExpressionComment->MaterialExpressionEditorX -= MaterialExpressionComment->SizeX;
FixRequirement(FString::Printf(TEXT("%s'%s'"), *ClassName, *Name), MaterialExpression);
}
else if (MaterialExpression)
{
Material->Expressions.Add(MaterialExpression);
FixRequirement(FString::Printf(TEXT("%s'%s'"), *ClassName, *Name), MaterialExpression);
}
if (ClassName == TEXT("MaterialExpressionFlipBookSample"))
{
ImportMaterialExpressionFlipBookSample((UMaterialExpressionTextureSample *)MaterialExpression, TextureRequirement);
}
}
else
{
JumpToEnd();
}
}
else if (GetProperty(TEXT("DiffuseColor="), Value))
{
ImportExpression(&Material->BaseColor);
}
else if (GetProperty(TEXT("SpecularColor="), Value))
{
ImportExpression(&Material->Specular);
}
else if (GetProperty(TEXT("SpecularPower="), Value))
{
// TODO
}
else if (GetProperty(TEXT("Normal="), Value))
{
ImportExpression(&Material->Normal);
}
else if (GetProperty(TEXT("EmissiveColor="), Value))
{
ImportExpression(&Material->EmissiveColor);
}
else if (GetProperty(TEXT("Opacity="), Value))
{
ImportExpression(&Material->Opacity);
}
else if (GetProperty(TEXT("OpacityMask="), Value))
{
ImportExpression(&Material->OpacityMask);
}
else if (IsProperty(Name, Value))
{
UProperty* Property = FindField<UProperty>(UMaterial::StaticClass(), *Name);
if (Property)
{
Property->ImportText(*Value, Property->ContainerPtrToValuePtr<uint8>(Material), 0, Material);
}
}
}
//.........这里部分代码省略.........
示例5: LoadOptions
void USpeedTreeImportData::LoadOptions()
{
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();
const FString& PropFileName = GEditorPerProjectIni;
UArrayProperty* Array = dynamic_cast<UArrayProperty*>(Property);
if (Array)
{
FConfigSection* Sec = GConfig->GetSectionPrivate(*Section, 0, 1, *GEditorPerProjectIni);
if (Sec != nullptr)
{
TArray<FConfigValue> List;
const FName KeyName(*Key, FNAME_Find);
Sec->MultiFind(KeyName, List);
FScriptArrayHelper_InContainer ArrayHelper(Array, this);
// Only override default properties if there is something to override them with.
if (List.Num() > 0)
{
ArrayHelper.EmptyAndAddValues(List.Num());
for (int32 i = List.Num() - 1, c = 0; i >= 0; i--, c++)
{
Array->Inner->ImportText(*List[i].GetValue(), ArrayHelper.GetRawPtr(c), PortFlags, this);
}
}
else
{
int32 Index = 0;
const FConfigValue* ElementValue = nullptr;
do
{
// Add array index number to end of key
FString IndexedKey = FString::Printf(TEXT("%s[%i]"), *Key, Index);
// Try to find value of key
const FName IndexedName(*IndexedKey, FNAME_Find);
if (IndexedName == NAME_None)
{
break;
}
ElementValue = Sec->Find(IndexedName);
// If found, import the element
if (ElementValue != nullptr)
{
// expand the array if necessary so that Index is a valid element
ArrayHelper.ExpandForIndex(Index);
Array->Inner->ImportText(*ElementValue->GetValue(), ArrayHelper.GetRawPtr(Index), PortFlags, this);
}
Index++;
} while (ElementValue || Index < ArrayHelper.Num());
}
}
}
else
{
for (int32 i = 0; i < Property->ArrayDim; i++)
{
if (Property->ArrayDim != 1)
{
Key = FString::Printf(TEXT("%s[%i]"), *Property->GetName(), i);
}
FString Value;
bool bFoundValue = GConfig->GetString(*Section, *Key, Value, *GEditorPerProjectIni);
if (bFoundValue)
{
if (Property->ImportText(*Value, Property->ContainerPtrToValuePtr<uint8>(this, i), PortFlags, this) == NULL)
{
// this should be an error as the properties from the .ini / .int file are not correctly being read in and probably are affecting things in subtle ways
UE_LOG(LogSpeedTreeImportData, Error, TEXT("SpeedTree Options LoadOptions (%s): failed for %s in: %s"), *GetPathName(), *Property->GetName(), *Value);
}
}
}
}
}
}