예제 #1
0
void USoundWave::PostLoad()
{
	Super::PostLoad();

	if (GetOutermost()->HasAnyPackageFlags(PKG_ReloadingForCooker))
	{
		return;
	}

	// Compress to whatever formats the active target platforms want
	// static here as an optimization
	ITargetPlatformManagerModule* TPM = GetTargetPlatformManager();
	if (TPM)
	{
		const TArray<ITargetPlatform*>& Platforms = TPM->GetActiveTargetPlatforms();

		for (int32 Index = 0; Index < Platforms.Num(); Index++)
		{
			GetCompressedData(Platforms[Index]->GetWaveFormat(this));
		}
	}

	// We don't precache default objects and we don't precache in the Editor as the latter will
	// most likely cause us to run out of memory.
	if (!GIsEditor && !IsTemplate( RF_ClassDefaultObject ) && GEngine)
	{
		FAudioDevice* AudioDevice = GEngine->GetMainAudioDevice();
		if (AudioDevice && AudioDevice->AreStartupSoundsPreCached())
		{
			// Upload the data to the hardware, but only if we've precached startup sounds already
			AudioDevice->Precache(this);
		}
		// remove bulk data if no AudioDevice is used and no sounds were initialized
		else if(IsRunningGame())
		{
			RawData.RemoveBulkData();
		}
	}

	// Only add this streaming sound if we're not a dedicated server or if there is an audio device manager
	if (IsStreaming() && !IsRunningDedicatedServer() && GEngine && GEngine->GetAudioDeviceManager())
	{
#if WITH_EDITORONLY_DATA
		FinishCachePlatformData();
#endif // #if WITH_EDITORONLY_DATA
		IStreamingManager::Get().GetAudioStreamingManager().AddStreamingSoundWave(this);
	}

#if WITH_EDITORONLY_DATA
	if (!SourceFilePath_DEPRECATED.IsEmpty() && AssetImportData)
	{
		FAssetImportInfo Info;
		Info.Insert(FAssetImportInfo::FSourceFile(SourceFilePath_DEPRECATED));
		AssetImportData->SourceData = MoveTemp(Info);
	}
#endif // #if WITH_EDITORONLY_DATA

	INC_FLOAT_STAT_BY( STAT_AudioBufferTime, Duration );
	INC_FLOAT_STAT_BY( STAT_AudioBufferTimeChannels, NumChannels * Duration );
}
TOptional<FAssetImportInfo> FAssetSourceFilenameCache::ExtractAssetImportInfo(const TArray<UObject::FAssetRegistryTag>& InTags)
{
	static const FName LegacySourceFilePathName("SourceFile");

	TOptional<FAssetImportInfo> Info;

	for (const auto& Tag : InTags)
	{
		if (Tag.Name == UObject::SourceFileTagName())
		{
			Info = FAssetImportInfo::FromJson(*Tag.Value);
			// We're done
			break;
		}
		else if (Tag.Name == LegacySourceFilePathName)
		{
			FAssetImportInfo Legacy;
			Legacy.Insert(Tag.Value);
			Info = Legacy;
			// Keep looking for a newer json version
		}
	}

	return Info;
}
예제 #3
0
void UTexture::PostLoad()
{
	Super::PostLoad();

#if WITH_EDITORONLY_DATA
	if (AssetImportData == nullptr)
	{
		AssetImportData = NewObject<UAssetImportData>(this, TEXT("AssetImportData"));
	}

	if (!SourceFilePath_DEPRECATED.IsEmpty())
	{
		FAssetImportInfo Info;
		Info.Insert(FAssetImportInfo::FSourceFile(SourceFilePath_DEPRECATED));
		AssetImportData->SourceData = MoveTemp(Info);
	}
#endif

	if( !IsTemplate() )
	{
		// Update cached LOD bias.
		UpdateCachedLODBias();

		// The texture will be cached by the cubemap it is contained within on consoles.
		UTextureCube* CubeMap = Cast<UTextureCube>(GetOuter());
		if (CubeMap == NULL)
		{
			// Recreate the texture's resource.
			UpdateResource();
		}
	}
}
예제 #4
0
void UCurveBase::PostLoad()
{
	Super::PostLoad();
	if (!ImportPath_DEPRECATED.IsEmpty() && AssetImportData)
	{
		FAssetImportInfo Info;
		Info.Insert(FAssetImportInfo::FSourceFile(ImportPath_DEPRECATED));
		AssetImportData->CopyFrom(Info);
	}
}
예제 #5
0
void UCurveTable::PostLoad()
{
	Super::PostLoad();
	if (!ImportPath_DEPRECATED.IsEmpty() && AssetImportData)
	{
		FAssetImportInfo Info;
		Info.Insert(FAssetImportInfo::FSourceFile(ImportPath_DEPRECATED));
		AssetImportData->SourceData = MoveTemp(Info);
	}
}
void UCreatureAnimationAsset::PostLoad()
{
	Super::PostLoad();

	if (!creature_filename.IsEmpty() && AssetImportData && AssetImportData->GetSourceData().SourceFiles.Num() == 0)
	{
		// convert old source file path to proper UE4 Asset data system
		FAssetImportInfo Info;
		Info.Insert(FAssetImportInfo::FSourceFile(creature_filename));
		AssetImportData->SourceData = MoveTemp(Info);
	}

	if (CreatureZipBinary.Num() != 0 || CreatureFileJSonData.IsEmpty() == false)
	{
		// load the animation data caches from the json data
		GatherAnimationData();
	}
}
TOptional<FAssetImportInfo> FAssetSourceFilenameCache::ExtractAssetImportInfo(const TSharedMapView<FName, FString>& InTags)
{
	static const FName LegacySourceFilePathName("SourceFile");

	if (const FString* ImportDataString = InTags.Find(UObject::SourceFileTagName()))
	{
		return FAssetImportInfo::FromJson(*ImportDataString);
	}
	else if (const FString* LegacyFilename = InTags.Find(LegacySourceFilePathName))
	{
		FAssetImportInfo Legacy;
		Legacy.Insert(*LegacyFilename);
		return Legacy;
	}
	else
	{
		return TOptional<FAssetImportInfo>();
	}
}