コード例 #1
0
bool UDiffAssetsCommandlet::LoadFile(const FString& Filename, TArray<UObject *>& LoadedObjects)
{
	UPackage* Package = Cast<UPackage>(LoadPackage( NULL, *Filename, LOAD_None ));
	if (!Package)
	{
		UE_LOG(LogDiffAssetsCommandlet, Warning, TEXT("Could not load %s"), *Filename);
		return false;
	}
	for (TObjectIterator<UObject> It; It; ++It)
	{
		if (It->GetOuter() == Package)
		{
			LoadedObjects.Add(*It);
		}
	}
	if (!LoadedObjects.Num())
	{
		UE_LOG(LogDiffAssetsCommandlet, Warning, TEXT("Loaded %s, but it didn't contain any objects."), *Filename);
		return false;
	}
	LoadedObjects.Sort();

	return true;
}
コード例 #2
0
void UExporter::ExportObjectInner(const FExportObjectInnerContext* Context, UObject* Object, FOutputDevice& Ar, uint32 PortFlags, bool bSkipComponents)
{
	// indent all the text in here
	TextIndent += 3;

	FExportObjectInnerContext::InnerList ObjectInners;
	if ( Context )
	{
		const FExportObjectInnerContext::InnerList* Inners = Context->ObjectToInnerMap.Find( Object );
		if ( Inners )
		{
			ObjectInners = *Inners;
		}
	}
	else
	{
		for (TObjectIterator<UObject> It; It; ++It)
		{
			if ( It->GetOuter() == Object )
			{
				ObjectInners.Add( *It );
			}
		}
	}


	TArray<UObject*> Components;
	if (!bSkipComponents)
	{
		// first export the components
		Object->CollectDefaultSubobjects(Components, false);
	}

	if (!(PortFlags & PPF_SeparateDefine))
	{
		for ( int32 ObjIndex = 0 ; ObjIndex < ObjectInners.Num() ; ++ObjIndex )
		{
			// NOTE: We ignore inner objects that have been tagged for death
			UObject* Obj = ObjectInners[ObjIndex];
			if ( !Obj->IsPendingKill() && !Obj->IsDefaultSubobject() && !Obj->HasAnyFlags(RF_TextExportTransient) && FCString::Stricmp(*Obj->GetClass()->GetName(), TEXT("Model")) != 0)
			{
				// export the object
				UExporter::ExportToOutputDevice( Context, Obj, NULL, Ar, (PortFlags & PPF_Copy) ? TEXT("Copy") : TEXT("T3D"), TextIndent, PortFlags | PPF_SeparateDeclare, false, ExportRootScope );
			}
		}

		if (!bSkipComponents)
		{
			ExportComponentDefinitions(Context, Components, Ar, PortFlags | PPF_SeparateDeclare);
		}
	}

	if (!(PortFlags & PPF_SeparateDeclare))
	{
		for ( int32 ObjIndex = 0 ; ObjIndex < ObjectInners.Num() ; ++ObjIndex )
		{
			// NOTE: We ignore inner objects that have been tagged for death
			UObject* Obj = ObjectInners[ObjIndex];
			if ( !Obj->IsPendingKill() && !Obj->IsDefaultSubobject() && !Obj->HasAnyFlags(RF_TextExportTransient) && FCString::Stricmp(*Obj->GetClass()->GetName(), TEXT("Model")) != 0)
			{
				// export the object
				UExporter::ExportToOutputDevice( Context, Obj, NULL, Ar, (PortFlags & PPF_Copy) ? TEXT("Copy") : TEXT("T3D"), TextIndent, PortFlags | PPF_SeparateDefine, false, ExportRootScope );

				// don't reexport below in ExportProperties
				Obj->Mark(OBJECTMARK_TagImp);
			}
		}

		if (!bSkipComponents)
		{
			ExportComponentDefinitions(Context, Components, Ar, PortFlags | PPF_SeparateDefine);
		}

		// export the object's properties
		// Note: we use archetype as the object to diff properties against before they exported. When object is created, they should create from archetype
		// and using this system, it should recover all properties it needs to copy
		uint8 *CompareObject;
		if (Object->HasAnyFlags(RF_ClassDefaultObject))
		{
			CompareObject = (uint8*)Object;
		}
		else
		{
			CompareObject = (uint8*)Object->GetArchetype();
		}
		ExportProperties( Context, Ar, Object->GetClass(), (uint8*)Object, TextIndent, Object->GetClass(), CompareObject, Object, PortFlags, ExportRootScope );

		if (!bSkipComponents)
		{
			// Export anything extra for the components. Used for instanced foliage.
			// This is done after the actor properties so these are set when regenerating the extra data objects.
			ExportComponentExtra( Context, Components, Ar, PortFlags );
		}
	}

	// remove indent
	TextIndent -= 3;
}