本文整理汇总了C++中UGameViewportClient::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ UGameViewportClient::Init方法的具体用法?C++ UGameViewportClient::Init怎么用?C++ UGameViewportClient::Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UGameViewportClient
的用法示例。
在下文中一共展示了UGameViewportClient::Init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
void UGameEngine::Init(IEngineLoop* InEngineLoop)
{
DECLARE_SCOPE_CYCLE_COUNTER(TEXT("UGameEngine Init"), STAT_GameEngineStartup, STATGROUP_LoadTime);
// Call base.
UEngine::Init(InEngineLoop);
#if USE_NETWORK_PROFILER
FString NetworkProfilerTag;
if( FParse::Value(FCommandLine::Get(), TEXT("NETWORKPROFILER="), NetworkProfilerTag ) )
{
GNetworkProfiler.EnableTracking(true);
}
#endif
// Load all of the engine modules that we need at startup that are not editor-related
UGameEngine::LoadRuntimeEngineStartupModules();
// Load and apply user game settings
GetGameUserSettings()->LoadSettings();
GetGameUserSettings()->ApplyNonResolutionSettings();
// Create game instance. For GameEngine, this should be the only GameInstance that ever gets created.
{
FStringClassReference GameInstanceClassName = GetDefault<UGameMapsSettings>()->GameInstanceClass;
UClass* GameInstanceClass = (GameInstanceClassName.IsValid() ? LoadObject<UClass>(NULL, *GameInstanceClassName.ToString()) : UGameInstance::StaticClass());
GameInstance = NewObject<UGameInstance>(this, GameInstanceClass);
GameInstance->InitializeStandalone();
}
// // Creates the initial world context. For GameEngine, this should be the only WorldContext that ever gets created.
// FWorldContext& InitialWorldContext = CreateNewWorldContext(EWorldType::Game);
// Initialize the viewport client.
UGameViewportClient* ViewportClient = NULL;
if(GIsClient)
{
ViewportClient = NewObject<UGameViewportClient>(this, GameViewportClientClass);
ViewportClient->Init(*GameInstance->GetWorldContext(), GameInstance);
GameViewport = ViewportClient;
GameInstance->GetWorldContext()->GameViewport = ViewportClient;
}
bCheckForMovieCapture = true;
// Attach the viewport client to a new viewport.
if(ViewportClient)
{
// This must be created before any gameplay code adds widgets
bool bWindowAlreadyExists = GameViewportWindow.IsValid();
if (!bWindowAlreadyExists)
{
GameViewportWindow = CreateGameWindow();
}
CreateGameViewport( ViewportClient );
if( !bWindowAlreadyExists )
{
SwitchGameWindowToUseGameViewport();
}
FString Error;
if(ViewportClient->SetupInitialLocalPlayer(Error) == NULL)
{
UE_LOG(LogEngine, Fatal,TEXT("%s"),*Error);
}
UGameViewportClient::OnViewportCreated().Broadcast();
}
GameInstance->StartGameInstance();
UE_LOG(LogInit, Display, TEXT("Game Engine Initialized.") );
// for IsInitialized()
bIsInitialized = true;
}
示例2: Main
int32 UUnitTestCommandlet::Main(const FString& Params)
{
// @todo #JohnBLowPri: Fix StandaloneRenderer support for static builds
#if IS_MONOLITHIC
UE_LOG(LogUnitTest, Log, TEXT("NetcodeUnitTest commandlet not currently supported in static/monolithic builds"));
#else
GIsRequestingExit = false;
// @todo #JohnBLowPri: Steam detection doesn't seem to work this early on, but does work further down the line;
// try to find a way, to detect it as early as possible
// NetcodeUnitTest is not compatible with Steam; if Steam is running/detected, abort immediately
// @todo #JohnBLowPri: Add support for Steam
if (NUTNet::IsSteamNetDriverAvailable())
{
UE_LOG(LogUnitTest, Log, TEXT("NetcodeUnitTest does not currently support Steam. Close Steam before running."));
GIsRequestingExit = true;
}
if (!GIsRequestingExit)
{
GIsRunning = true;
// Hack-set the engine GameViewport, so that setting GIsClient, doesn't cause an auto-exit
// @todo JohnB: If you later remove the GIsClient setting code below, remove this as well
if (GEngine->GameViewport == NULL)
{
UGameEngine* GameEngine = Cast<UGameEngine>(GEngine);
// GameInstace = GameEngine->GameInstance;
UGameInstance* GameInstance = GET_PRIVATE(UGameEngine, GameEngine, GameInstance);
if (GameEngine != NULL)
{
UGameViewportClient* NewViewport = NewObject<UGameViewportClient>(GameEngine);
FWorldContext* CurContext = GameInstance->GetWorldContext();
GameEngine->GameViewport = NewViewport;
NewViewport->Init(*CurContext, GameInstance);
// Set the internal FViewport, for the new game viewport, to avoid another bit of auto-exit code
NewViewport->Viewport = new FDummyViewport(NewViewport);
// Set the main engine world context game viewport, to match the newly created viewport, in order to prevent crashes
CurContext->GameViewport = NewViewport;
}
}
// Now, after init stages are done, enable GIsClient for netcode and such
GIsClient = true;
// Before running any unit tests, create a world object, which will contain the unit tests manager etc.
// (otherwise, when the last unit test world is cleaned up, the unit test manager stops functioning)
UWorld* UnitTestWorld = NUTNet::CreateUnitTestWorld(false);
const TCHAR* ParamsRef = *Params;
FString UnitTestParam = TEXT("");
FString UnitCmd = TEXT("UnitTest ");
if (FParse::Value(ParamsRef, TEXT("UnitTest="), UnitTestParam))
{
UnitCmd += UnitTestParam;
}
else
{
UnitCmd += TEXT("all");
}
GEngine->Exec(UnitTestWorld, *UnitCmd);
// NOTE: This main loop is partly based off of FileServerCommandlet
while (GIsRunning && !GIsRequestingExit)
{
GEngine->UpdateTimeAndHandleMaxTickRate();
GEngine->Tick(FApp::GetDeltaTime(), false);
if (FSlateApplication::IsInitialized())
{
FSlateApplication::Get().PumpMessages();
FSlateApplication::Get().Tick();
}
// Execute deferred commands
for (int32 DeferredCommandsIndex=0; DeferredCommandsIndex<GEngine->DeferredCommands.Num(); DeferredCommandsIndex++)
{
GEngine->Exec(UnitTestWorld, *GEngine->DeferredCommands[DeferredCommandsIndex], *GLog);
}
GEngine->DeferredCommands.Empty();
FPlatformProcess::Sleep(0);
//.........这里部分代码省略.........
示例3: Init
void UGameEngine::Init(IEngineLoop* InEngineLoop)
{
DECLARE_SCOPE_CYCLE_COUNTER(TEXT("UGameEngine Init"), STAT_GameEngineStartup, STATGROUP_LoadTime);
// Call base.
UEngine::Init(InEngineLoop);
#if USE_NETWORK_PROFILER
FString NetworkProfilerTag;
if( FParse::Value(FCommandLine::Get(), TEXT("NETWORKPROFILER="), NetworkProfilerTag ) )
{
GNetworkProfiler.EnableTracking(true);
}
#endif
// Load and apply user game settings
GetGameUserSettings()->LoadSettings();
GetGameUserSettings()->ApplySettings();
// Creates the initial world context. For GameEngine, this should be the only WorldContext that ever gets created.
FWorldContext &InitialWorldContext = CreateNewWorldContext(EWorldType::Game);
// Initialize the viewport client.
UGameViewportClient* ViewportClient = NULL;
if(GIsClient)
{
ViewportClient = ConstructObject<UGameViewportClient>(GameViewportClientClass,this);
ViewportClient->SetReferenceToWorldContext(InitialWorldContext);
GameViewport = ViewportClient;
InitialWorldContext.GameViewport = ViewportClient;
}
bCheckForMovieCapture = true;
// Attach the viewport client to a new viewport.
if(ViewportClient)
{
// This must be created before any gameplay code adds widgets
bool bWindowAlreadyExists = GameViewportWindow.IsValid();
if (!bWindowAlreadyExists)
{
GameViewportWindow = CreateGameWindow();
}
CreateGameViewport( ViewportClient );
if( !bWindowAlreadyExists )
{
SwitchGameWindowToUseGameViewport();
}
FString Error;
if(!ViewportClient->Init(Error))
{
UE_LOG(LogEngine, Fatal,TEXT("%s"),*Error);
}
}
// Create default URL.
// @note: if we change how we determine the valid start up map update LaunchEngineLoop's GetStartupMap()
FURL DefaultURL;
DefaultURL.LoadURLConfig( TEXT("DefaultPlayer"), GGameIni );
// Enter initial world.
EBrowseReturnVal::Type BrowseRet = EBrowseReturnVal::Failure;
FString Error;
TCHAR Parm[4096]=TEXT("");
const TCHAR* Tmp = FCommandLine::Get();
#if UE_BUILD_SHIPPING
// In shipping don't allow an override
Tmp = TEXT("");
#endif // UE_BUILD_SHIPPING
const UGameMapsSettings* GameMapsSettings = GetDefault<UGameMapsSettings>();
const FString& DefaultMap = GameMapsSettings->GetGameDefaultMap();
if (!FParse::Token(Tmp, Parm, ARRAY_COUNT(Parm), 0) || Parm[0] == '-')
{
FCString::Strcpy(Parm, *(DefaultMap + GameMapsSettings->LocalMapOptions));
}
FURL URL( &DefaultURL, Parm, TRAVEL_Partial );
if( URL.Valid )
{
BrowseRet = Browse(InitialWorldContext, URL, Error );
}
// If waiting for a network connection, go into the starting level.
if (BrowseRet != EBrowseReturnVal::Success && FCString::Stricmp(Parm, *DefaultMap) != 0)
{
const FText Message = FText::Format( NSLOCTEXT("Engine", "MapNotFound", "The map specified on the commandline '{0}' could not be found. Would you like to load the default map instead?"), FText::FromString( URL.Map ) );
// the map specified on the command-line couldn't be loaded. ask the user if we should load the default map instead
if ( FCString::Stricmp(*URL.Map, *DefaultMap) != 0 &&
FMessageDialog::Open( EAppMsgType::OkCancel, Message ) != EAppReturnType::Ok)
{
// user canceled (maybe a typo while attempting to run a commandlet)
FPlatformMisc::RequestExit( false );
return;
}
else
{
//.........这里部分代码省略.........