本文整理汇总了C++中UObject类的典型用法代码示例。如果您正苦于以下问题:C++ UObject类的具体用法?C++ UObject怎么用?C++ UObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveOpenAssetEditors
void FAssetEditorManager::SaveOpenAssetEditors(bool bOnShutdown)
{
if(!bSavingOnShutdown)
{
TArray<FString> OpenAssets;
// Don't save a list of assets to restore if we are running under a debugger
if(!FPlatformMisc::IsDebuggerPresent())
{
for (auto EditorPair : OpenedEditors)
{
IAssetEditorInstance* Editor = EditorPair.Key;
if (Editor != NULL)
{
UObject* EditedObject = EditorPair.Value;
if(EditedObject != NULL)
{
// only record assets that have a valid saved package
UPackage* Package = EditedObject->GetOutermost();
if(Package != NULL && Package->GetFileSize() != 0)
{
OpenAssets.Add(EditedObject->GetPathName());
}
}
}
}
}
GConfig->SetArray(TEXT("AssetEditorManager"), TEXT("OpenAssetsAtExit"), OpenAssets, GEditorPerProjectIni);
GConfig->SetBool(TEXT("AssetEditorManager"), TEXT("CleanShutdown"), bOnShutdown, GEditorPerProjectIni);
GConfig->Flush(false, GEditorPerProjectIni);
}
}
示例2: Clear
void ObjectHash::Clear()
{
bool any;
do
{
any = false;
unsigned skipped = 0;
for ( OH_iterator itr = hash.begin(), itrend = hash.end(); itr != itrend; )
{
UObject* obj = ( *itr ).second.get();
if ( obj->orphan() && obj->ref_counted_count() == 1 )
{
hash.erase( itr++ );
any = true;
}
else
{
++skipped;
++itr;
}
}
} while ( any );
if ( !hash.empty() )
{
INFO_PRINT << "Leftover objects in objecthash: " << hash.size() << "\n";
// the hash will be cleared after main() exits, with other statics.
// this usually causes assertion failures and crashes.
// creating a copy of the internal hash will ensure no refcounts reach zero.
INFO_PRINT << "Leaking a copy of the objecthash in order to avoid a crash.\n";
new hs( hash );
}
// hash.clear();
}
示例3: GetObjectName
FText SGraphPinObject::GetObjectName() const
{
FText Value = FText::GetEmpty();
if (GraphPinObj != NULL)
{
UObject* DefaultObject = GraphPinObj->DefaultObject;
if (DefaultObject != NULL)
{
Value = FText::FromString(DefaultObject->GetName());
int32 StringLen = Value.ToString().Len();
//If string is too long, then truncate (eg. "abcdefgijklmnopq" is converted as "abcd...nopq")
const int32 MaxAllowedLength = 16;
if (StringLen > MaxAllowedLength)
{
//Take first 4 characters
FString TruncatedStr(Value.ToString().Left(4));
TruncatedStr += FString( TEXT("..."));
//Take last 4 characters
TruncatedStr += Value.ToString().Right(4);
Value = FText::FromString(TruncatedStr);
}
}
}
return Value;
}
示例4: ObjectReferenceCollector
void FContentComparisonHelper::RecursiveObjectCollection(UObject* InStartObject, int32 InCurrDepth, int32 InMaxDepth, TMap<UObject*,bool>& OutCollectedReferences)
{
// Serialize object with reference collector.
TArray<UObject*> LocalCollectedReferences;
FReferenceFinder ObjectReferenceCollector( LocalCollectedReferences, NULL, false, true, true, true );
ObjectReferenceCollector.FindReferences( InStartObject );
if (InCurrDepth < InMaxDepth)
{
InCurrDepth++;
for (int32 ObjRefIdx = 0; ObjRefIdx < LocalCollectedReferences.Num(); ObjRefIdx++)
{
UObject* InnerObject = LocalCollectedReferences[ObjRefIdx];
if ((InnerObject != NULL) &&
(InnerObject->IsA(UFunction::StaticClass()) == false) &&
(InnerObject->IsA(UPackage::StaticClass()) == false)
)
{
OutCollectedReferences.Add(InnerObject, true);
RecursiveObjectCollection(InnerObject, InCurrDepth, InMaxDepth, OutCollectedReferences);
}
}
InCurrDepth--;
}
}
示例5: GetEnumForByteTrack
UEnum* GetEnumForByteTrack(TSharedPtr<ISequencer> Sequencer, const FGuid& OwnerObjectHandle, FName PropertyName, UMovieSceneByteTrack* ByteTrack)
{
UObject* RuntimeObject = Sequencer->GetFocusedMovieSceneSequence()->FindObject(OwnerObjectHandle);
TSet<UEnum*> PropertyEnums;
if (RuntimeObject != nullptr)
{
UProperty* Property = RuntimeObject->GetClass()->FindPropertyByName(PropertyName);
if (Property != nullptr)
{
UByteProperty* ByteProperty = Cast<UByteProperty>(Property);
if (ByteProperty != nullptr && ByteProperty->Enum != nullptr)
{
PropertyEnums.Add(ByteProperty->Enum);
}
}
}
UEnum* TrackEnum;
if (PropertyEnums.Num() == 1)
{
TrackEnum = PropertyEnums.Array()[0];
}
else
{
TrackEnum = nullptr;
}
return TrackEnum;
}
示例6: FindClass
// Finds the class for the given stack state.
UStruct* FindClass( const FReadState& State )
{
UStruct* Class = nullptr;
if (State.Property != nullptr)
{
UProperty* ParentProperty = State.Property;
UArrayProperty* ArrayProperty = Cast<UArrayProperty>(ParentProperty);
if (ArrayProperty != nullptr)
{
ParentProperty = ArrayProperty->Inner;
}
UStructProperty* StructProperty = Cast<UStructProperty>(ParentProperty);
UObjectPropertyBase* ObjectProperty = Cast<UObjectPropertyBase>(ParentProperty);
if (StructProperty != nullptr)
{
Class = StructProperty->Struct;
}
else if (ObjectProperty != nullptr)
{
Class = ObjectProperty->PropertyClass;
}
}
else
{
UObject* RootObject = static_cast<UObject*>(State.Data);
Class = RootObject->GetClass();
}
return Class;
}
示例7: LoadAssetsFromPaths
int32 UObjectLibrary::LoadAssetsFromPaths(const TArray<FString>& Paths)
{
int32 Count = 0;
if (bIsFullyLoaded)
{
// We already ran this
return 0;
}
bIsFullyLoaded = true;
for (int PathIndex = 0; PathIndex < Paths.Num(); PathIndex++)
{
TArray<UObject*> LoadedObjects;
FString Path = Paths[PathIndex];
if (EngineUtils::FindOrLoadAssetsByPath(Path, LoadedObjects, bHasBlueprintClasses ? EngineUtils::ATL_Class : EngineUtils::ATL_Regular))
{
for (int32 i = 0; i < LoadedObjects.Num(); ++i)
{
UObject* Object = LoadedObjects[i];
if (Object == NULL || (ObjectBaseClass && !Object->IsA(ObjectBaseClass)))
{
// Incorrect type, skip
continue;
}
AddObject(Object);
Count++;
}
}
}
return Count;
}
示例8: GetOuter
/**
* Internal version of GetPathName() that eliminates unnecessary copies.
*/
void UObjectBaseUtility::GetPathName( const UObject* StopOuter, FString& ResultString ) const
{
if( this != StopOuter && this != NULL )
{
UObject* Outer = GetOuter();
if ( Outer && Outer != StopOuter )
{
Outer->GetPathName( StopOuter, ResultString );
// SUBOBJECT_DELIMITER is used to indicate that this object's outer is not a UPackage
if (Outer->GetClass() != UPackage::StaticClass()
&& Outer->GetOuter()->GetClass() == UPackage::StaticClass())
{
ResultString += SUBOBJECT_DELIMITER;
}
else
{
ResultString += TEXT(".");
}
}
AppendName(ResultString);
}
else
{
ResultString += TEXT("None");
}
}
示例9: CurrentObject
FArchiveGenerateReferenceGraph::FArchiveGenerateReferenceGraph( FReferenceGraph& OutGraph )
: CurrentObject(NULL),
ObjectGraph(OutGraph)
{
ArIsObjectReferenceCollector = true;
ArIgnoreOuterRef = true;
// Iterate over each object..
for( FObjectIterator It; It; ++It )
{
UObject* Object = *It;
// Skip transient and those about to be deleted
if( !Object->HasAnyFlags( RF_Transient | RF_PendingKill ) )
{
// only serialize non actors objects which have not been visited.
// actors are skipped because we have don't need them to show the reference tree
// @todo, may need to serialize them later for full reference graph.
if( !VisitedObjects.Find( Object ) && !Object->IsA( AActor::StaticClass() ) )
{
// Set the current object to the one we are about to serialize
CurrentObject = Object;
// This object has been visited. Any serializations after this should skip this object
VisitedObjects.Add( Object );
Object->Serialize( *this );
}
}
}
}
示例10: UE_LOG
int32 UFixupNeedsLoadForEditorGameCommandlet::InitializeResaveParameters(const TArray<FString>& Tokens, TArray<FString>& MapPathNames)
{
int32 Result = Super::InitializeResaveParameters(Tokens, MapPathNames);
// We need ResaveClasses to be specified, otherwise we won't know what to update
if (Result == 0 && !ResaveClasses.Num())
{
UE_LOG(LogContentCommandlet, Error, TEXT("FixupNeedsLoadForEditorGame commandlet requires at least one resave class name. Use -RESAVECLASS=ClassA,ClassB,ClassC to specify resave classes."));
Result = 1;
}
else
{
for (FName& ClassName : ResaveClasses)
{
if (!ResaveClassNeedsLoadForEditorGameValues.Contains(ClassName))
{
UClass* ResaveClass = FindObject<UClass>(ANY_PACKAGE, *ClassName.ToString());
if (ResaveClass)
{
UObject* DefaultObject = ResaveClass->GetDefaultObject();
ResaveClassNeedsLoadForEditorGameValues.Add(ClassName, DefaultObject->NeedsLoadForEditorGame());
}
}
else if (Verbosity != UResavePackagesCommandlet::ONLY_ERRORS)
{
UE_LOG(LogContentCommandlet, Warning, TEXT("Resave Class \"%s\" could not be found. Make sure the class name is valid and that it's a native class."), *ClassName.ToString());
}
}
if (ResaveClassNeedsLoadForEditorGameValues.Num() == 0)
{
UE_LOG(LogContentCommandlet, Error, TEXT("Got %d classes to resave but none of the exist."), ResaveClasses.Num());
Result = 1;
}
}
return Result;
}
示例11: UE_LOG
void FObjectReplicator::PostReceivedBunch()
{
if ( GetObject() == NULL )
{
UE_LOG(LogNet, Verbose, TEXT("PostReceivedBunch: Object == NULL"));
return;
}
// Call PostNetReceive
const bool bIsServer = (OwningChannel->Connection->Driver->ServerConnection == NULL);
if (!bIsServer && bHasReplicatedProperties)
{
PostNetReceive();
bHasReplicatedProperties = false;
}
// Check if PostNetReceive() destroyed Object
UObject *Object = GetObject();
if (Object == NULL || Object->IsPendingKill())
{
return;
}
// Call RepNotifies
CallRepNotifies(true);
}
示例12: GetBlueprint
void UK2Node_MacroInstance::PostPasteNode()
{
const UBlueprint* InstanceOwner = GetBlueprint();
// Find the owner of the macro graph
const UEdGraph* MacroGraph = MacroGraphReference.GetGraph();
UObject* MacroOwner = MacroGraph->GetOuter();
UBlueprint* MacroOwnerBP = NULL;
while(MacroOwner)
{
MacroOwnerBP = Cast<UBlueprint>(MacroOwner);
if(MacroOwnerBP)
{
break;
}
MacroOwner = MacroOwner->GetOuter();
}
if((MacroOwnerBP != NULL)
&& (MacroOwnerBP->BlueprintType != BPTYPE_MacroLibrary)
&& (MacroOwnerBP != InstanceOwner))
{
// If this is a graph from another blueprint that is NOT a library, disallow the connection!
MacroGraphReference.SetGraph(NULL);
}
Super::PostPasteNode();
}
示例13: SetBestBaseClass
// Looks at the Objects array and returns the best base class. Called by
// Finalize(); that is, when the list of selected objects is being finalized.
void FObjectPropertyNode::SetBestBaseClass()
{
BaseClass = NULL;
for( int32 x = 0 ; x < Objects.Num() ; ++x )
{
UObject* Obj = Objects[x].Get();
if( Obj )
{
UClass* ObjClass = Cast<UClass>(Obj);
if (ObjClass == NULL)
{
ObjClass = Obj->GetClass();
}
check( ObjClass );
// Initialize with the class of the first object we encounter.
if( BaseClass == NULL )
{
BaseClass = ObjClass;
}
// If we've encountered an object that's not a subclass of the current best baseclass,
// climb up a step in the class hierarchy.
while( !ObjClass->IsChildOf( BaseClass.Get() ) )
{
BaseClass = BaseClass->GetSuperClass();
}
}
}
}
示例14: GetResults
int32 FObjectMemoryAnalyzer::GetResults(TArray<FObjectMemoryUsage>& Results)
{
if (BaseClass != NULL)
{
uint32 ExclusionFlags = (AnalyzeFlags&EAnalyzeFlags::IncludeDefaultObjects)==0 ? (RF_ClassDefaultObject|RF_ArchetypeObject) : 0;
for( FObjectIterator It(BaseClass, false, (EObjectFlags)ExclusionFlags); It; ++It )
{
UObject* Object = *It;
if (!(AnalyzeFlags&EAnalyzeFlags::IncludeDefaultObjects) && Object->IsDefaultSubobject()) { continue; };
FObjectMemoryUsage& Annotation = MemUsageAnnotations.GetAnnotationRef(Object);
if (Annotation.IsRoot())
{
Annotation.Object = Object;
Results.Add(Annotation);
}
}
}
if (ObjectList.Num() > 0)
{
for (int32 i=0; i < ObjectList.Num(); ++i)
{
FObjectMemoryUsage& Annotation = MemUsageAnnotations.GetAnnotationRef(ObjectList[i]);
check(Annotation.IsRoot());
Annotation.Object = ObjectList[i];
Results.Add(Annotation);
}
}
return Results.Num();
}
示例15: Outer1
TSharedPtr<FGraphNodeClassNode> FGraphNodeClassHelper::CreateClassDataNode(const class FAssetData& AssetData)
{
TSharedPtr<FGraphNodeClassNode> Node;
const FString* GeneratedClassname = AssetData.TagsAndValues.Find("GeneratedClass");
const FString* ParentClassname = AssetData.TagsAndValues.Find("ParentClass");
if (GeneratedClassname && ParentClassname)
{
FString AssetClassName = *GeneratedClassname;
UObject* Outer1(NULL);
ResolveName(Outer1, AssetClassName, false, false);
FString AssetParentClassName = *ParentClassname;
UObject* Outer2(NULL);
ResolveName(Outer2, AssetParentClassName, false, false);
Node = MakeShareable(new FGraphNodeClassNode);
Node->ParentClassName = AssetParentClassName;
UObject* AssetOb = AssetData.IsAssetLoaded() ? AssetData.GetAsset() : NULL;
UBlueprint* AssetBP = Cast<UBlueprint>(AssetOb);
UClass* AssetClass = AssetBP ? *AssetBP->GeneratedClass : AssetOb ? AssetOb->GetClass() : NULL;
FGraphNodeClassData NewData(AssetData.AssetName.ToString(), AssetData.PackageName.ToString(), AssetClassName, AssetClass);
Node->Data = NewData;
}
return Node;
}