• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ULevelStreaming类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ULevelStreaming的典型用法代码示例。如果您正苦于以下问题:C++ ULevelStreaming类的具体用法?C++ ULevelStreaming怎么用?C++ ULevelStreaming使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ULevelStreaming类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: FlushLevelStreaming

void UWorld::RefreshStreamingLevels( const TArray<class ULevelStreaming*>& InLevelsToRefresh )
{
	// Reassociate levels in case we changed streaming behavior. Editor-only!
	if( GIsEditor )
	{
		// Load and associate levels if necessary.
		FlushLevelStreaming();

		// Remove all currently visible levels.
		for( int32 LevelIndex=0; LevelIndex<InLevelsToRefresh.Num(); LevelIndex++ )
		{
			ULevelStreaming* StreamingLevel = InLevelsToRefresh[LevelIndex];
			ULevel* LoadedLevel = StreamingLevel ? StreamingLevel->GetLoadedLevel() : nullptr;

			if( LoadedLevel &&
				LoadedLevel->bIsVisible )
			{
				RemoveFromWorld( LoadedLevel );
			}
		}

		// Load and associate levels if necessary.
		FlushLevelStreaming();

		// Update the level browser so it always contains valid data
		FEditorSupportDelegates::WorldChange.Broadcast();
	}
}
开发者ID:magetron,项目名称:UnrealEngine4-mod,代码行数:28,代码来源:LevelActor.cpp


示例2: AddRequiredLevels

	void AddRequiredLevels( EStaticMeshLightingInfoObjectSets InObjectSet, UWorld* InWorld, TArray<ULevel*>& OutLevels )
	{
		switch (InObjectSet)
		{ 
		case StaticMeshLightingInfoObjectSets_CurrentLevel:
			{
				check(InWorld);
				OutLevels.AddUnique(InWorld->GetCurrentLevel());
			}
			break;
		case StaticMeshLightingInfoObjectSets_SelectedLevels:
			{
				TArray<class ULevel*>& SelectedLevels = InWorld->GetSelectedLevels();
				for(auto It = SelectedLevels.CreateIterator(); It; ++It)
				{
					ULevel* Level = *It;
					if (Level)
					{
						OutLevels.AddUnique(Level);
					}
				}

				if (OutLevels.Num() == 0)
				{
					// Fall to the current level...
					check(InWorld);
					OutLevels.AddUnique(InWorld->GetCurrentLevel());
				}
			}
			break;
		case StaticMeshLightingInfoObjectSets_AllLevels:
			{
				if (InWorld != NULL)
				{
					// Add main level.
					OutLevels.AddUnique(InWorld->PersistentLevel);

					// Add secondary levels.
					for (int32 LevelIndex = 0; LevelIndex < InWorld->StreamingLevels.Num(); ++LevelIndex)
					{
						ULevelStreaming* StreamingLevel = InWorld->StreamingLevels[LevelIndex];
						if ( StreamingLevel != NULL )
						{
							ULevel* Level = StreamingLevel->GetLoadedLevel();
							if ( Level != NULL )
							{
								OutLevels.AddUnique( Level );
							}
						}
					}
				}
			}
			break;
		}
	}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:55,代码来源:StaticMeshLightingInfoStatsPage.cpp


示例3: TickDemoRecord

void UDemoNetDriver::TickFlush( float DeltaSeconds )
{
	Super::TickFlush( DeltaSeconds );

	if ( FileAr )
	{
		if ( ClientConnections.Num() > 0 )
		{
			TickDemoRecord( DeltaSeconds );
		}
		else if ( ServerConnection != NULL )
		{
			// Wait until all levels are streamed in
			for ( int32 i = 0; i < World->StreamingLevels.Num(); ++i )
			{
				ULevelStreaming * StreamingLevel = World->StreamingLevels[i];
				if ( StreamingLevel != NULL && ( !StreamingLevel->IsLevelLoaded() || !StreamingLevel->GetLoadedLevel()->GetOutermost()->IsFullyLoaded() || !StreamingLevel->IsLevelVisible() ) )
				{
					// Abort, we have more streaming levels to load
					return;
				}
			}

			World->GetWorldSettings()->DemoPlayTimeDilation = CVarDemoTimeDilation.GetValueOnGameThread();

			// Clamp time between 1000 hz, and 2 hz 
			// (this is useful when debugging and you set a breakpoint, you don't want all that time to pass in one frame)
			DeltaSeconds = FMath::Clamp( DeltaSeconds, 1.0f / 1000.0f, 1.0f / 2.0f );

			// We need to compensate for the fact that DeltaSeconds is real-time for net drivers
			DeltaSeconds *= World->GetWorldSettings()->GetEffectiveTimeDilation();

			// Update time dilation on spectator pawn to compensate for any demo dilation 
			//	(we want to continue to fly around in real-time)
			if ( SpectatorController != NULL )
			{
				if ( SpectatorController->GetSpectatorPawn() != NULL )
				{
					// Disable collision on the spectator
					SpectatorController->GetSpectatorPawn()->SetActorEnableCollision( false );
					
					// Apply time dilation on spectator to reverse the effects of global dilation
					SpectatorController->GetSpectatorPawn()->CustomTimeDilation = 1.0f / World->GetWorldSettings()->DemoPlayTimeDilation;
				}
			}

			if ( bDemoPlaybackDone )
			{
				return;
			}

			TickDemoPlayback( DeltaSeconds );
		}
	}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:55,代码来源:DemoNetDriver.cpp


示例4: GetLevelObject

ULevel* FStreamingLevelModel::GetLevelObject() const
{
	ULevelStreaming* StreamingObj = LevelStreaming.Get();
	
	if (StreamingObj)
	{
		return StreamingObj->GetLoadedLevel();
	}
	else // persistent level does not have associated level streaming object
	{
		return LevelCollectionModel.GetWorld()->PersistentLevel;
	}
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:13,代码来源:StreamingLevelModel.cpp


示例5: IsStreamingMethodChecked

bool FStreamingLevelCollectionModel::IsStreamingMethodChecked(UClass* InClass) const
{
	for (auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
	{
		TSharedPtr<FStreamingLevelModel> TargetModel = StaticCastSharedPtr<FStreamingLevelModel>(*It);
		ULevelStreaming* LevelStreaming = TargetModel->GetLevelStreaming().Get();
		
		if (LevelStreaming && LevelStreaming->GetClass() == InClass)
		{
			return true;
		}
	}
	return false;
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:14,代码来源:StreamingLevelCollectionModel.cpp


示例6: GetWorlds

/**
* Assembles the set of all referenced worlds.
*
* @param	OutWorlds			[out] The set of referenced worlds.
* @param	bIncludeGWorld		If true, include GWorld in the output list.
* @param	bOnlyEditorVisible	If true, only sub-levels that should be visible in-editor are included
*/
void GetWorlds(UWorld* InWorld, TArray<UWorld*>& OutWorlds, bool bIncludeInWorld, bool bOnlyEditorVisible)
{
    OutWorlds.Empty();
    if ( bIncludeInWorld )
    {
        OutWorlds.AddUnique( InWorld );
    }

    // Iterate over the world's level array to find referenced levels ("worlds"). We don't
    for ( int32 LevelIndex = 0 ; LevelIndex < InWorld->StreamingLevels.Num() ; ++LevelIndex )
    {
        ULevelStreaming* StreamingLevel = InWorld->StreamingLevels[LevelIndex];
        if ( StreamingLevel )
        {
            // If we asked for only sub-levels that are editor-visible, then limit our results appropriately
            bool bShouldAlwaysBeLoaded = false; // Cast< ULevelStreamingAlwaysLoaded >( StreamingLevel ) != NULL;
            if( !bOnlyEditorVisible || bShouldAlwaysBeLoaded || StreamingLevel->bShouldBeVisibleInEditor )
            {
                const ULevel* Level = StreamingLevel->GetLoadedLevel();

                // This should always be the case for valid level names as the Editor preloads all packages.
                if ( Level != NULL )
                {
                    // Newer levels have their packages' world as the outer.
                    UWorld* World = Cast<UWorld>( Level->GetOuter() );
                    if ( World != NULL )
                    {
                        OutWorlds.AddUnique( World );
                    }
                }
            }
        }
    }

    // Levels can be loaded directly without StreamingLevel facilities
    for ( int32 LevelIndex = 0 ; LevelIndex < InWorld->GetLevels().Num() ; ++LevelIndex )
    {
        ULevel* Level = InWorld->GetLevel(LevelIndex);
        if ( Level )
        {
            // Newer levels have their packages' world as the outer.
            UWorld* World = Cast<UWorld>( Level->GetOuter() );
            if ( World != NULL )
            {
                OutWorlds.AddUnique( World );
            }
        }
    }
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:56,代码来源:EditorLevelUtils.cpp


示例7: GetLevelStreamingForPackageName

/** Utility for returning the ULevelStreaming object for a particular sub-level, specified by package name */
ULevelStreaming* UWorld::GetLevelStreamingForPackageName(FName InPackageName)
{
	// iterate over each level streaming object
	for( int32 LevelIndex=0; LevelIndex<StreamingLevels.Num(); LevelIndex++ )
	{
		ULevelStreaming* LevelStreaming = StreamingLevels[LevelIndex];
		// see if name matches
		if(LevelStreaming && LevelStreaming->GetWorldAssetPackageFName() == InPackageName)
		{
			// it doesn't, return this one
			return LevelStreaming;
		}
	}

	// failed to find one
	return NULL;
}
开发者ID:magetron,项目名称:UnrealEngine4-mod,代码行数:18,代码来源:LevelActor.cpp


示例8: ChangeColor

void FLevelViewModel::ChangeColor(const TSharedRef<SWidget>& InPickerParentWidget)
{
	if( !Level.IsValid() )
	{
		return;
	}

	if ( !Level->IsPersistentLevel())
	{
		// Initialize the color data for the picker window.
		ULevelStreaming* StreamingLevel = FLevelUtils::FindStreamingLevel( Level.Get() );
		check( StreamingLevel );

		FLinearColor NewColor = StreamingLevel->LevelColor;
		TArray<FLinearColor*> ColorArray;
		ColorArray.Add(&NewColor);

		FColorPickerArgs PickerArgs;
		PickerArgs.bIsModal = true;
		PickerArgs.DisplayGamma = TAttribute<float>::Create( TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma) );
		PickerArgs.LinearColorArray = &ColorArray;
		PickerArgs.OnColorPickerCancelled = FOnColorPickerCancelled::CreateSP(this, &FLevelViewModel::OnColorPickerCancelled);
		PickerArgs.ParentWidget = InPickerParentWidget;

		// ensure this is true, will be set to false in OnColorPickerCancelled if necessary
		bColorPickerOK = true;
		if (OpenColorPicker(PickerArgs))
		{
			if ( bColorPickerOK )
			{
				StreamingLevel->LevelColor = NewColor;
				StreamingLevel->Modify();

				// Update the loaded level's components so the change in color will apply immediately
				ULevel* LoadedLevel = StreamingLevel->GetLoadedLevel();
				if ( LoadedLevel )
				{
					LoadedLevel->UpdateLevelComponents(false);
				}

				ULevel::LevelDirtiedEvent.Broadcast();
			}
			FEditorSupportDelegates::RedrawAllViewports.Broadcast();
		}
	}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:46,代码来源:LevelViewModel.cpp


示例9: check

void FEditorModeTools::SetBookmark( uint32 InIndex, FEditorViewportClient* InViewportClient )
{
	UWorld* World = InViewportClient->GetWorld();
	if ( World )
	{
		AWorldSettings* WorldSettings = World->GetWorldSettings();

		// Verify the index is valid for the bookmark
		if ( WorldSettings && InIndex < AWorldSettings::MAX_BOOKMARK_NUMBER )
		{
			// If the index doesn't already have a bookmark in place, create a new one
			if ( !WorldSettings->BookMarks[ InIndex ] )
			{
				WorldSettings->BookMarks[ InIndex ] = ConstructObject<UBookMark>( UBookMark::StaticClass(), WorldSettings );
			}

			UBookMark* CurBookMark = WorldSettings->BookMarks[ InIndex ];
			check(CurBookMark);
			check(InViewportClient);

			// Use the rotation from the first perspective viewport can find.
			FRotator Rotation(0,0,0);
			if( !InViewportClient->IsOrtho() )
			{
				Rotation = InViewportClient->GetViewRotation();
			}

			CurBookMark->Location = InViewportClient->GetViewLocation();
			CurBookMark->Rotation = Rotation;

			// Keep a record of which levels were hidden so that we can restore these with the bookmark
			CurBookMark->HiddenLevels.Empty();
			for ( int32 LevelIndex = 0 ; LevelIndex < World->StreamingLevels.Num() ; ++LevelIndex )
			{
				ULevelStreaming* StreamingLevel = World->StreamingLevels[LevelIndex];
				if ( StreamingLevel )
				{
					if( !StreamingLevel->bShouldBeVisibleInEditor )
					{
						CurBookMark->HiddenLevels.Add( StreamingLevel->GetFullName() );
					}
				}
			}
		}
	}
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:46,代码来源:EditorModeManager.cpp


示例10: PrivateRemoveLevelFromWorld

/**
* Removes a level from the world.  Returns true if the level was removed successfully.
*
* @param	Level		The level to remove from the world.
* @return				true if the level was removed successfully, false otherwise.
*/
bool PrivateRemoveLevelFromWorld(ULevel* Level)
{
    if ( !Level || Level->IsPersistentLevel() )
    {
        return false;
    }

    if ( FLevelUtils::IsLevelLocked(Level) )
    {
        FMessageDialog::Open( EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "Error_OperationDisallowedOnLockedLevelRemoveLevelFromWorld", "RemoveLevelFromWorld: The requested operation could not be completed because the level is locked.") );
        return false;
    }

    int32 StreamingLevelIndex = INDEX_NONE;

    for( int32 LevelIndex = 0 ; LevelIndex < Level->OwningWorld->StreamingLevels.Num() ; ++LevelIndex )
    {
        ULevelStreaming* StreamingLevel = Level->OwningWorld->StreamingLevels[ LevelIndex ];
        if( StreamingLevel && StreamingLevel->GetLoadedLevel() == Level )
        {
            StreamingLevelIndex = LevelIndex;
            break;
        }
    }

    if (StreamingLevelIndex != INDEX_NONE)
    {
        Level->OwningWorld->StreamingLevels[StreamingLevelIndex]->MarkPendingKill();
        Level->OwningWorld->StreamingLevels.RemoveAt( StreamingLevelIndex );
        Level->OwningWorld->RefreshStreamingLevels();
    }
    else if (Level->bIsVisible)
    {
        Level->OwningWorld->RemoveFromWorld(Level);
        check(Level->bIsVisible == false);
    }

    const bool bSuccess = EditorDestroyLevel(Level);
    // Since we just removed all the actors from this package, we do not want it to be saved out now
    // and the user was warned they would lose any changes from before removing, so we're good to clear
    // the dirty flag
    UPackage* LevelPackage = Level->GetOutermost();
    LevelPackage->SetDirtyFlag(false);

    return bSuccess;
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:52,代码来源:EditorLevelUtils.cpp


示例11: check

void FLevelModel::UpdateSimulationStatus(UWorld* InWorld)
{
	check(InWorld);
	SimulationStatus = FSimulationLevelStatus();
	
	// Matcher for finding streaming level in PIE world by package name
	struct FSimulationLevelStreamingMatcher
	{
		FSimulationLevelStreamingMatcher( const FName& InPackageName )
			: PackageName( InPackageName )
		{}

		bool Matches( const ULevelStreaming* Candidate ) const
		{
			if (Candidate->PackageNameToLoad != NAME_None)
			{
				return Candidate->PackageNameToLoad == PackageName;
			}
			return Candidate->PackageName == PackageName;
		}

		FName PackageName;
	};
	
	// Find corresponding streaming level
	int32 StreamingLevelIdx = InWorld->StreamingLevels.FindMatch(FSimulationLevelStreamingMatcher(GetLongPackageName()));
	if (StreamingLevelIdx != INDEX_NONE)
	{
		ULevelStreaming* StreamingLevel = InWorld->StreamingLevels[StreamingLevelIdx];

		if (StreamingLevel->GetLoadedLevel())
		{
			SimulationStatus.bLoaded = true;
				
			if (StreamingLevel->GetLoadedLevel()->bIsVisible)
			{
				SimulationStatus.bVisible = true;
			}
		}
		else if (StreamingLevel->bHasLoadRequestPending)
		{
			SimulationStatus.bLoading = true;
		}
	}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:45,代码来源:LevelModel.cpp


示例12: PackageName

/**
 * Returns the streaming level by package name, or NULL if none exists.
 *
 * @param		PackageName		Name of the package containing the ULevel to query
 * @return						The level's streaming level, or NULL if none exists.
 */
ULevelStreaming* FLevelUtils::FindStreamingLevel(UWorld* InWorld, const TCHAR* InPackageName)
{
	const FName PackageName( InPackageName );
	ULevelStreaming* MatchingLevel = NULL;
	if( InWorld)
	{
		for( int32 LevelIndex = 0 ; LevelIndex< InWorld->StreamingLevels.Num() ; ++LevelIndex )
		{
			ULevelStreaming* CurStreamingLevel = InWorld->StreamingLevels[ LevelIndex ];
			if( CurStreamingLevel && CurStreamingLevel->GetWorldAssetPackageFName() == PackageName )
			{
				MatchingLevel = CurStreamingLevel;
				break;
			}
		}
	}
	return MatchingLevel;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:24,代码来源:LevelUtils.cpp


示例13: check

void FLevelViewModel::RefreshStreamingLevelIndex()
{
	if ( IsLevel() )
	{
		UWorld *OwningWorld = Level->OwningWorld;
		check( OwningWorld );

		for( int32 LevelIndex = 0 ; LevelIndex < OwningWorld->StreamingLevels.Num() ; ++LevelIndex )
		{
			ULevelStreaming *StreamingLevel = OwningWorld->StreamingLevels[LevelIndex];
			if ( Level.Get() == StreamingLevel->GetLoadedLevel() )
			{
				StreamingLevelIndex = LevelIndex;
				LevelStreaming = StreamingLevel;
				break;
			}
		}
	}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:19,代码来源:LevelViewModel.cpp


示例14: GetWorld

bool UWorldComposition::UpdateEditorStreamingState(const FVector& InLocation)
{
	UWorld* OwningWorld = GetWorld();
	bool bStateChanged = false;
	
	// Handle only editor worlds
	if (!OwningWorld->IsGameWorld() && 
		!OwningWorld->IsVisibilityRequestPending())
	{
		// Get the list of visible and hidden levels from current view point
		TArray<FDistanceVisibleLevel> DistanceVisibleLevels;
		TArray<FDistanceVisibleLevel> DistanceHiddenLevels;
		GetDistanceVisibleLevels(InLocation, DistanceVisibleLevels, DistanceHiddenLevels);

		// Hidden levels
		for (const auto& Level : DistanceHiddenLevels)
		{
			ULevelStreaming* EditorStreamingLevel = OwningWorld->GetLevelStreamingForPackageName(TilesStreaming[Level.TileIdx]->GetWorldAssetPackageFName());
			if (EditorStreamingLevel && 
				EditorStreamingLevel->IsLevelLoaded() &&
				EditorStreamingLevel->bShouldBeVisibleInEditor != false)
			{
				EditorStreamingLevel->bShouldBeVisibleInEditor = false;
				bStateChanged = true;
			}
		}

		// Visible levels
		for (const auto& Level : DistanceVisibleLevels)
		{
			ULevelStreaming* EditorStreamingLevel = OwningWorld->GetLevelStreamingForPackageName(TilesStreaming[Level.TileIdx]->GetWorldAssetPackageFName());
			if (EditorStreamingLevel &&
				EditorStreamingLevel->IsLevelLoaded() &&
				EditorStreamingLevel->bShouldBeVisibleInEditor != true)
			{
				EditorStreamingLevel->bShouldBeVisibleInEditor = true;
				bStateChanged = true;
			}
		}
	}

	return bStateChanged;
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:43,代码来源:WorldComposition.cpp


示例15: FindStreamingLevel

/**
 * Returns the streaming level corresponding to the specified ULevel, or NULL if none exists.
 *
 * @param		Level		The level to query.
 * @return					The level's streaming level, or NULL if none exists.
 */
ULevelStreaming* FLevelUtils::FindStreamingLevel(const ULevel* Level)
{
	ULevelStreaming* MatchingLevel = NULL;

	if (Level && Level->OwningWorld)
	{
		for( int32 LevelIndex = 0 ; LevelIndex < Level->OwningWorld->StreamingLevels.Num() ; ++LevelIndex )
		{
			ULevelStreaming* CurStreamingLevel = Level->OwningWorld->StreamingLevels[ LevelIndex ];
			if( CurStreamingLevel && CurStreamingLevel->GetLoadedLevel() == Level )
			{
				MatchingLevel = CurStreamingLevel;
				break;
			}
		}
	}

	return MatchingLevel;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:25,代码来源:LevelUtils.cpp


示例16: GetWorld

ULevelStreaming* ULevelStreaming::CreateInstance(FString InstanceUniqueName)
{
	ULevelStreaming* StreamingLevelInstance = nullptr;
	
	UWorld* InWorld = GetWorld();
	if (InWorld)
	{
		// Create instance long package name 
		FString InstanceShortPackageName = InWorld->StreamingLevelsPrefix + FPackageName::GetShortName(InstanceUniqueName);
		FString InstancePackagePath = FPackageName::GetLongPackagePath(GetWorldAssetPackageName()) + TEXT("/");
		FName	InstanceUniquePackageName = FName(*(InstancePackagePath + InstanceShortPackageName));

		// check if instance name is unique among existing streaming level objects
		const bool bUniqueName = (InWorld->StreamingLevels.IndexOfByPredicate(ULevelStreaming::FPackageNameMatcher(InstanceUniquePackageName)) == INDEX_NONE);
				
		if (bUniqueName)
		{
			StreamingLevelInstance = NewObject<ULevelStreaming>(InWorld, GetClass(), NAME_None, RF_Transient, NULL);
			// new level streaming instance will load the same map package as this object
			StreamingLevelInstance->PackageNameToLoad = (PackageNameToLoad == NAME_None ? GetWorldAssetPackageFName() : PackageNameToLoad);
			// under a provided unique name
			StreamingLevelInstance->SetWorldAssetByPackageName(InstanceUniquePackageName);
			StreamingLevelInstance->bShouldBeLoaded = false;
			StreamingLevelInstance->bShouldBeVisible = false;
			StreamingLevelInstance->LevelTransform = LevelTransform;

			// add a new instance to streaming level list
			InWorld->StreamingLevels.Add(StreamingLevelInstance);
		}
		else
		{
			UE_LOG(LogStreaming, Warning, TEXT("Provided streaming level instance name is not unique: %s"), *InstanceUniquePackageName.ToString());
		}
	}
	
	return StreamingLevelInstance;
}
开发者ID:ErwinT6,项目名称:T6Engine,代码行数:37,代码来源:LevelStreaming.cpp


示例17: GetLevelStreamingStatus

/** This will set the StreamingLevels TMap with the current Streaming Level Status and also set which level the player is in **/
void GetLevelStreamingStatus( UWorld* World, TMap<FName,int32>& StreamingLevels, FString& LevelPlayerIsInName )
{
	FWorldContext &Context = GEngine->WorldContextFromWorld(World);

	// Iterate over the world info's level streaming objects to find and see whether levels are loaded, visible or neither.
	for( int32 LevelIndex=0; LevelIndex<World->StreamingLevels.Num(); LevelIndex++ )
	{
		ULevelStreaming* LevelStreaming = World->StreamingLevels[LevelIndex];

		if( LevelStreaming 
			&&  LevelStreaming->PackageName != NAME_None 
			&&	LevelStreaming->PackageName != World->GetOutermost()->GetFName() )
		{
			ULevel* Level = LevelStreaming->GetLoadedLevel();
			if( Level != NULL )
			{
				if( World->ContainsLevel( Level ) == true )
				{
					if( World->CurrentLevelPendingVisibility == Level )
					{
						StreamingLevels.Add( LevelStreaming->PackageName, LEVEL_MakingVisible );
					}
					else
					{
						StreamingLevels.Add( LevelStreaming->PackageName, LEVEL_Visible );
					}
				}
				else
				{
					StreamingLevels.Add( LevelStreaming->PackageName, LEVEL_Loaded );
				}
			}
			else
			{
				// See whether the level's world object is still around.
				UPackage* LevelPackage	= Cast<UPackage>(StaticFindObjectFast( UPackage::StaticClass(), NULL, LevelStreaming->PackageName ));
				UWorld*	  LevelWorld	= NULL;
				if( LevelPackage )
				{
					LevelWorld = UWorld::FindWorldInPackage(LevelPackage);
				}

				if( LevelWorld )
				{
					StreamingLevels.Add( LevelStreaming->PackageName, LEVEL_UnloadedButStillAround );
				}
				else if( GetAsyncLoadPercentage( *LevelStreaming->PackageName.ToString() ) >= 0 )
				{
					StreamingLevels.Add( LevelStreaming->PackageName, LEVEL_Loading );
				}
				else
				{
					StreamingLevels.Add( LevelStreaming->PackageName, LEVEL_Unloaded );
				}
			}
		}
	}

	
	// toss in the levels being loaded by PrepareMapChange
	for( int32 LevelIndex=0; LevelIndex < Context.LevelsToLoadForPendingMapChange.Num(); LevelIndex++ )
	{
		const FName LevelName = Context.LevelsToLoadForPendingMapChange[LevelIndex];
		StreamingLevels.Add(LevelName, LEVEL_Preloading);
	}


	ULevel* LevelPlayerIsIn = NULL;

	for( FConstPlayerControllerIterator Iterator = World->GetPlayerControllerIterator(); Iterator; ++Iterator )
	{
		APlayerController* PlayerController = *Iterator;

		if( PlayerController->GetPawn() != NULL )
		{
			// need to do a trace down here
			//TraceActor = Trace( out_HitLocation, out_HitNormal, TraceDest, TraceStart, false, TraceExtent, HitInfo, true );
			FHitResult Hit(1.f);

			// this will not work for flying around :-(
			static FName NAME_FindLevel = FName(TEXT("FindLevel"), true);			
			PlayerController->GetWorld()->LineTraceSingle(Hit,PlayerController->GetPawn()->GetActorLocation(), (PlayerController->GetPawn()->GetActorLocation()-FVector(0.f, 0.f, 256.f)), FCollisionQueryParams(NAME_FindLevel, true, PlayerController->GetPawn()), FCollisionObjectQueryParams(ECC_WorldStatic));

			/** @todo UE4 FIXME
			if( Hit.Level != NULL )
			{
				LevelPlayerIsIn = Hit.Level;
			}
			else 
			*/
			if( Hit.GetActor() != NULL )
			{
				LevelPlayerIsIn = Hit.GetActor()->GetLevel();
			}
			else if( Hit.Component != NULL && Hit.Component->GetOwner() != NULL )
			{
				AActor* Owner = Hit.Component->GetOwner();
				if (Owner)
				{
//.........这里部分代码省略.........
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:101,代码来源:EngineUtils.cpp


示例18: SetLevelVisibility

void SetLevelVisibility(ULevel* Level, bool bShouldBeVisible, bool bForceLayersVisible)
{
    // Nothing to do
    if ( Level == NULL )
    {
        return;
    }


    // Handle the case of the p-level
    // The p-level can't be unloaded, so its actors/BSP should just be temporarily hidden/unhidden
    // Also, intentionally do not force layers visible for the p-level
    if ( Level->IsPersistentLevel() )
    {
        //create a transaction so we can undo the visibilty toggle
        const FScopedTransaction Transaction( LOCTEXT( "ToggleLevelVisibility", "Toggle Level Visibility" ) );
        if ( Level->bIsVisible != bShouldBeVisible )
        {
            Level->Modify();
        }
        // Set the visibility of each actor in the p-level
        for ( TArray<AActor*>::TIterator PLevelActorIter( Level->Actors ); PLevelActorIter; ++PLevelActorIter )
        {
            AActor* CurActor = *PLevelActorIter;
            if ( CurActor && !FActorEditorUtils::IsABuilderBrush(CurActor) && CurActor->bHiddenEdLevel == bShouldBeVisible )
            {
                CurActor->Modify();
                CurActor->bHiddenEdLevel = !bShouldBeVisible;
                CurActor->RegisterAllComponents();
                CurActor->MarkComponentsRenderStateDirty();
            }
        }

        // Set the visibility of each BSP surface in the p-level
        UModel* CurLevelModel = Level->Model;
        if ( CurLevelModel )
        {
            CurLevelModel->Modify();
            for ( TArray<FBspSurf>::TIterator SurfaceIterator( CurLevelModel->Surfs ); SurfaceIterator; ++SurfaceIterator )
            {
                FBspSurf& CurSurf = *SurfaceIterator;
                CurSurf.bHiddenEdLevel = !bShouldBeVisible;
            }
        }

        // Add/remove model components from the scene
        for(int32 ComponentIndex = 0; ComponentIndex < Level->ModelComponents.Num(); ComponentIndex++)
        {
            UModelComponent* CurLevelModelCmp = Level->ModelComponents[ComponentIndex];
            if(CurLevelModelCmp)
            {
                if (bShouldBeVisible && CurLevelModelCmp)
                {
                    CurLevelModelCmp->RegisterComponentWithWorld(Level->OwningWorld);
                }
                else if (!bShouldBeVisible && CurLevelModelCmp->IsRegistered())
                {
                    CurLevelModelCmp->UnregisterComponent();
                }
            }
        }

        FEditorSupportDelegates::RedrawAllViewports.Broadcast();
    }
    else
    {
        ULevelStreaming* StreamingLevel = NULL;
        if (Level->OwningWorld == NULL || Level->OwningWorld->PersistentLevel != Level )
        {
            StreamingLevel = FLevelUtils::FindStreamingLevel( Level );
        }

        // If were hiding a level, lets make sure to close the level transform mode if its the same level currently selected for edit
        FEdModeLevel* LevelMode = static_cast<FEdModeLevel*>(GEditorModeTools().GetActiveMode( FBuiltinEditorModes::EM_Level ));
        if( LevelMode && LevelMode->IsEditing( StreamingLevel ) )
        {
            GEditorModeTools().DeactivateMode( FBuiltinEditorModes::EM_Level );
        }

        //create a transaction so we can undo the visibilty toggle
        const FScopedTransaction Transaction( LOCTEXT( "ToggleLevelVisibility", "Toggle Level Visibility" ) );

        // Handle the case of a streaming level
        if ( StreamingLevel )
        {
            // We need to set the RF_Transactional to make a streaming level serialize itself. so store the original ones, set the flag, and put the original flags back when done
            EObjectFlags cachedFlags = StreamingLevel->GetFlags();
            StreamingLevel->SetFlags( RF_Transactional );
            StreamingLevel->Modify();
            StreamingLevel->SetFlags( cachedFlags );

            // Set the visibility state for this streaming level.
            StreamingLevel->bShouldBeVisibleInEditor = bShouldBeVisible;
        }

        if( !bShouldBeVisible )
        {
            GEditor->Layers->RemoveLevelLayerInformation( Level );
        }

//.........这里部分代码省略.........
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:101,代码来源:EditorLevelUtils.cpp


示例19: switch

void FPrimitiveStatsPage::Generate( TArray< TWeakObjectPtr<UObject> >& OutObjects ) const
{
	PrimitiveStatsGenerator Generator;
	Generator.Generate();

	switch ((EPrimitiveObjectSets)ObjectSetIndex)
	{
		case PrimitiveObjectSets_CurrentLevel:
		{
			for (TObjectIterator<UPrimitiveComponent> It; It; ++It)
			{
				AActor* Owner = Cast<AActor>((*It)->GetOwner());

				if (Owner != nullptr && !Owner->HasAnyFlags(RF_ClassDefaultObject) && Owner->IsInLevel(GWorld->GetCurrentLevel()))
				{
					UPrimitiveStats* StatsEntry = Generator.Add(*It, (EPrimitiveObjectSets)ObjectSetIndex);

					if (StatsEntry != nullptr)
					{
						OutObjects.Add(StatsEntry);
					}
				}
			}
		}
		break;

		case PrimitiveObjectSets_AllObjects:
		{
			if (GWorld != NULL)
			{
				TArray<ULevel*> Levels;

				// Add main level.
				Levels.AddUnique(GWorld->PersistentLevel);

				// Add secondary levels.
				for (int32 LevelIndex = 0; LevelIndex < GWorld->StreamingLevels.Num(); ++LevelIndex)
				{
					ULevelStreaming* StreamingLevel = GWorld->StreamingLevels[LevelIndex];
					if (StreamingLevel != nullptr)
					{
						ULevel* Level = StreamingLevel->GetLoadedLevel();
						if (Level != nullptr)
						{
							Levels.AddUnique(Level);
						}
					}
				}

				for (TObjectIterator<UPrimitiveComponent> It; It; ++It)
				{
					AActor* Owner = Cast<AActor>((*It)->GetOwner());

					if (Owner != nullptr && !Owner->HasAnyFlags(RF_ClassDefaultObject))
					{
						ULevel* CheckLevel = Owner->GetLevel();

						if (CheckLevel != nullptr && (Levels.Contains(CheckLevel)))
						{
							UPrimitiveStats* StatsEntry = Generator.Add(*It, (EPrimitiveObjectSets)ObjectSetIndex);

							if (StatsEntry != nullptr)
							{
								OutObjects.Add(StatsEntry);
							}
						}
					}
				}
			}
		}
		break;

		case PrimitiveObjectSets_SelectedObjects:
		{
			TArray<UObject*> SelectedActors;
			GEditor->GetSelectedActors()->GetSelectedObjects(AActor::StaticClass(), SelectedActors);

			for (TObjectIterator<UPrimitiveComponent> It; It; ++It)
			{
				AActor* Owner = Cast<AActor>((*It)->GetOwner());
				if (Owner != nullptr && !Owner->HasAnyFlags(RF_ClassDefaultObject) && SelectedActors.Contains(Owner))
				{
					UPrimitiveStats* StatsEntry = Generator.Add(*It, (EPrimitiveObjectSets)ObjectSetIndex);
					if (StatsEntry != nullptr)
					{
						OutObjects.Add(StatsEntry);
					}
				}
			}
		}
		break;
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:93,代码来源:PrimitiveStatsPage.cpp


示例20: NSLOCTEXT

void UUnrealEdEngine::SelectNone(bool bNoteSelectionChange, bool bDeselectBSPSurfs, bool WarnAboutManyActors)
{
	if( GEdSelectionLock )
	{
		return;
	}

	bool bShowProgress = false;

	// If there are a lot of actors to process, pop up a warning "are you sure?" box
	if( WarnAboutManyActors )
	{
		int32 NumSelectedActors = GEditor->GetSelectedActorCount();
		if( NumSelectedActors >= EditorActorSelectionDefs::MaxActorsToSelectBeforeWarning )
		{
			bShowProgress = true;

			const FText ConfirmText = FText::Format( NSLOCTEXT("UnrealEd", "Warning_ManyActorsForDeselect", "There are {0} selected actors. Are you sure you want to deselect them all?" ), FText::AsNumber(NumSelectedActors) );

			FSuppressableWarningDialog::FSetupInfo Info( ConfirmText, NSLOCTEXT( "UnrealEd", "Warning_ManyActors", "Warning: Many Actors" ), "Warning_ManyActors" );
			Info.ConfirmText = NSLOCTEXT("ModalDialogs", "ManyActorsForDeselectConfirm", "Continue Deselection");
			Info.CancelText = NSLOCTEXT("ModalDialogs", "ManyActorsForDeselectCancel", "Keep Current Selection");

			FSuppressableWarningDialog ManyActorsWarning( Info );
			if( ManyActorsWarning.ShowModal() == FSuppressableWarningDialog::Cancel )
			{
				return;
			}
		}
	}

	if( bShowProgress )
	{
		GWarn->BeginSlowTask( LOCTEXT("BeginDeselectingActorsTaskMessage", "Deselecting Actors"), true );
	}

	// Make a list of selected actors . . .
	TArray<AActor*> ActorsToDeselect;
	for ( FSelectionIterator It( GetSelectedActorIterator() ) ; It ; ++It )
	{
		AActor* Actor = static_cast<AActor*>( *It );
		checkSlow( Actor->IsA(AActor::StaticClass()) );

		ActorsToDeselect.Add( Actor );
	}

	USelection* SelectedActors = GetSelectedActors();
	SelectedActors->BeginBatchSelectOperation();
	SelectedActors->Modify();

	// . . . and deselect them.
	for ( int32 ActorIndex = 0 ; ActorIndex < ActorsToDeselect.Num() ; ++ActorIndex )
	{
		AActor* Actor = ActorsToDeselect[ ActorIndex ];
		SelectActor( Actor, false, false );
	}

	uint32 NumDeselectSurfaces = 0;
	UWorld* World = GWorld;
	if( bDeselectBSPSurfs && World )
	{
		// Unselect all surfaces in all levels.
		NumDeselectSurfaces += DeselectAllSurfacesForLevel( World->PersistentLevel );
		for( int32 LevelIndex = 0 ; LevelIndex < World->StreamingLevels.Num() ; ++LevelIndex )
		{
			ULevelStreaming* StreamingLevel = World->StreamingLevels[LevelIndex];
			if( StreamingLevel )
			{
				ULevel* Level = StreamingLevel->GetLoadedLevel();
				if ( Level != NULL )
				{
					NumDeselectSurfaces += DeselectAllSurfacesForLevel( Level );
				}
			}
		}
	}

	SelectedActors->EndBatchSelectOperation(bNoteSelectionChange);

	//prevents clicking on background multiple times spamming selection changes
	if (ActorsToDeselect.Num() || NumDeselectSurfaces)
	{
		GetSelectedActors()->DeselectAll();

		if( bNoteSelectionChange )
		{
			NoteSelectionChange();
		}

		//whenever selection changes, recompute whether the selection contains a locked actor
		bCheckForLockActors = true;

		//whenever selection changes, recompute whether the selection contains a world info actor
		bCheckForWorldSettingsActors = true;
	}

	if( bShowProgress )
	{
		GWarn->EndSlowTask();
	}
//.........这里部分代码省略.........
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:101,代码来源:EditorSelectUtils.cpp



注:本文中的ULevelStreaming类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ UList类代码示例发布时间:2022-05-31
下一篇:
C++ ULevel类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap