本文整理汇总了C++中TSharedPtr::AddChild方法的典型用法代码示例。如果您正苦于以下问题:C++ TSharedPtr::AddChild方法的具体用法?C++ TSharedPtr::AddChild怎么用?C++ TSharedPtr::AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSharedPtr
的用法示例。
在下文中一共展示了TSharedPtr::AddChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AttachTo
bool FLevelModel::AttachTo(TSharedPtr<FLevelModel> InParent)
{
if (LevelCollectionModel.IsReadOnly() ||
!IsLoaded() ||
IsPersistent() ||
InParent.IsValid() == false ||
InParent.Get() == this ||
HasDescendant(InParent))
{
return false;
}
TSharedPtr<FLevelModel> CurrentParent = GetParent();
if (CurrentParent.IsValid())
{
CurrentParent->RemoveChild(this->AsShared());
}
Parent = InParent;
CurrentParent = GetParent();
if (CurrentParent.IsValid())
{
CurrentParent->AddChild(this->AsShared());
}
OnParentChanged();
return true;
}
示例2: AddClass
void FNativeClassHierarchy::AddClass(UClass* InClass, const TSet<FName>& InGameModules, const TMap<FName, FName>& InPluginModules, FAddClassMetrics& AddClassMetrics)
{
// Ignore deprecated and temporary classes
if(InClass->HasAnyClassFlags(CLASS_Deprecated | CLASS_NewerVersionExists) || FKismetEditorUtilities::IsClassABlueprintSkeleton(InClass))
{
return;
}
const FName ClassModuleName = GetClassModuleName(InClass);
if(ClassModuleName.IsNone())
{
return;
}
static const FName ModuleRelativePathMetaDataKey = "ModuleRelativePath";
const FString& ClassModuleRelativeIncludePath = InClass->GetMetaData(ModuleRelativePathMetaDataKey);
if(ClassModuleRelativeIncludePath.IsEmpty())
{
return;
}
// Work out which root this class should go under
const FName RootNodeName = GetClassPathRootForModule(ClassModuleName, InGameModules, InPluginModules);
// Work out the final path to this class within the hierarchy (which isn't the same as the path on disk)
const FString ClassModuleRelativePath = ClassModuleRelativeIncludePath.Left(ClassModuleRelativeIncludePath.Find(TEXT("/"), ESearchCase::CaseSensitive, ESearchDir::FromEnd));
const FString ClassHierarchyPath = ClassModuleName.ToString() + TEXT("/") + ClassModuleRelativePath;
// Ensure we've added a valid root node
TSharedPtr<FNativeClassHierarchyNode>& RootNode = RootNodes.FindOrAdd(RootNodeName);
if(!RootNode.IsValid())
{
RootNode = FNativeClassHierarchyNode::MakeFolderEntry(RootNodeName, TEXT("/") + RootNodeName.ToString());
++AddClassMetrics.NumFoldersAdded;
}
// Split the class path and ensure we have nodes for each part
TArray<FString> HierarchyPathParts;
ClassHierarchyPath.ParseIntoArray(HierarchyPathParts, TEXT("/"), true);
TSharedPtr<FNativeClassHierarchyNode> CurrentNode = RootNode;
for(const FString& HierarchyPathPart : HierarchyPathParts)
{
const FName HierarchyPathPartName = *HierarchyPathPart;
TSharedPtr<FNativeClassHierarchyNode>& ChildNode = CurrentNode->Children.FindOrAdd(FNativeClassHierarchyNodeKey(HierarchyPathPartName, ENativeClassHierarchyNodeType::Folder));
if(!ChildNode.IsValid())
{
ChildNode = FNativeClassHierarchyNode::MakeFolderEntry(HierarchyPathPartName, CurrentNode->EntryPath + TEXT("/") + HierarchyPathPart);
++AddClassMetrics.NumFoldersAdded;
}
CurrentNode = ChildNode;
}
// Now add the final entry for the class
CurrentNode->AddChild(FNativeClassHierarchyNode::MakeClassEntry(InClass, ClassModuleName, ClassModuleRelativePath, CurrentNode->EntryPath + TEXT("/") + InClass->GetName()));
++AddClassMetrics.NumClassesAdded;
}
示例3: OnLevelsCollectionChanged
void FStreamingLevelCollectionModel::OnLevelsCollectionChanged()
{
InvalidSelectedLevels.Empty();
// We have to have valid world
if (!CurrentWorld.IsValid())
{
return;
}
// Add model for a persistent level
TSharedPtr<FStreamingLevelModel> PersistentLevelModel = MakeShareable(new FStreamingLevelModel(Editor, *this, NULL));
PersistentLevelModel->SetLevelExpansionFlag(true);
RootLevelsList.Add(PersistentLevelModel);
AllLevelsList.Add(PersistentLevelModel);
AllLevelsMap.Add(PersistentLevelModel->GetLongPackageName(), PersistentLevelModel);
// Add models for each streaming level in the world
for (auto It = CurrentWorld->StreamingLevels.CreateConstIterator(); It; ++It)
{
ULevelStreaming* StreamingLevel = (*It);
if (StreamingLevel != NULL)
{
TSharedPtr<FStreamingLevelModel> LevelModel = MakeShareable(new FStreamingLevelModel(Editor, *this, StreamingLevel));
AllLevelsList.Add(LevelModel);
AllLevelsMap.Add(LevelModel->GetLongPackageName(), LevelModel);
PersistentLevelModel->AddChild(LevelModel);
LevelModel->SetParent(PersistentLevelModel);
}
}
FLevelCollectionModel::OnLevelsCollectionChanged();
// Sync levels selection to world
SetSelectedLevelsFromWorld();
}