本文整理汇总了C++中UMaterial::MarkPackageDirty方法的典型用法代码示例。如果您正苦于以下问题:C++ UMaterial::MarkPackageDirty方法的具体用法?C++ UMaterial::MarkPackageDirty怎么用?C++ UMaterial::MarkPackageDirty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UMaterial
的用法示例。
在下文中一共展示了UMaterial::MarkPackageDirty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PostEditChangeProperty
//.........这里部分代码省略.........
VectorParameters.RemoveAt(MaxVectorParameters, VectorParameters.Num() - MaxVectorParameters);
}
// Generate a new Id so that unloaded materials that reference this collection will update correctly on load
StateId = FGuid::NewGuid();
// Update the uniform buffer layout
CreateBufferStruct();
// Recreate each instance of this collection
for (TObjectIterator<UWorld> It; It; ++It)
{
UWorld* CurrentWorld = *It;
CurrentWorld->AddParameterCollectionInstance(this, false);
}
// Build set of changed parameter names
TSet<FName> ParameterNames;
for (const FCollectionVectorParameter& Param : PreviousVectorParameters)
{
ParameterNames.Add(Param.ParameterName);
}
for (const FCollectionScalarParameter& Param : PreviousScalarParameters)
{
ParameterNames.Add(Param.ParameterName);
}
for (const FCollectionVectorParameter& Param : VectorParameters)
{
ParameterNames.Remove(Param.ParameterName);
}
for (const FCollectionScalarParameter& Param : ScalarParameters)
{
ParameterNames.Remove(Param.ParameterName);
}
// Create a material update context so we can safely update materials using this parameter collection.
{
FMaterialUpdateContext UpdateContext;
// Go through all materials in memory and recompile them if they use this material parameter collection
for (TObjectIterator<UMaterial> It; It; ++It)
{
UMaterial* CurrentMaterial = *It;
bool bRecompile = false;
// Preview materials often use expressions for rendering that are not in their Expressions array,
// And therefore their MaterialParameterCollectionInfos are not up to date.
if (CurrentMaterial->bIsPreviewMaterial)
{
bRecompile = true;
}
else
{
for (int32 FunctionIndex = 0; FunctionIndex < CurrentMaterial->MaterialParameterCollectionInfos.Num() && !bRecompile; FunctionIndex++)
{
if (CurrentMaterial->MaterialParameterCollectionInfos[FunctionIndex].ParameterCollection == this)
{
TArray<UMaterialExpressionCollectionParameter*> CollectionParameters;
CurrentMaterial->GetAllExpressionsInMaterialAndFunctionsOfType(CollectionParameters);
for (UMaterialExpressionCollectionParameter* CollectionParameter : CollectionParameters)
{
if (ParameterNames.Contains(CollectionParameter->ParameterName))
{
bRecompile = true;
break;
}
}
}
}
}
if (bRecompile)
{
UpdateContext.AddMaterial(CurrentMaterial);
// Propagate the change to this material
CurrentMaterial->PreEditChange(NULL);
CurrentMaterial->PostEditChange();
CurrentMaterial->MarkPackageDirty();
}
}
}
}
// Update each world's scene with the new instance, and update each instance's uniform buffer to reflect the changes made by the user
for (TObjectIterator<UWorld> It; It; ++It)
{
UWorld* CurrentWorld = *It;
CurrentWorld->UpdateParameterCollectionInstances(true);
}
PreviousScalarParameters.Empty();
PreviousVectorParameters.Empty();
Super::PostEditChangeProperty(PropertyChangedEvent);
}