private void CheckIfNeedToCreateCamera() { if (this._cameraTransform != null) { return; } var mainChar = this.GetControllingCharacter(); if (mainChar == null) { return; } #if UnityAddressables this._playerCamera = CAssets.LoadAndInstantiate <CPlayerCamera>("PlayerCamera"); this._playerCamera.name = $"[CAM] {mainChar.name}"; Debug.Log($"Created {mainChar.name} Camera", this._playerCamera); this._playerCamera.Initialize(this); this._cameraTransform = this._playerCamera.GetCameraTransform(); #else Debug.LogError("Default player camera creation not implemented without UnityAddressables"); #endif }
public CLoading() { this._disposables?.Dispose(); this._disposables = new CompositeDisposable(); this._loadingCanvas = CAssets.LoadAndInstantiate <CLoadingCanvas>("Loading Canvas"); this._loadingUIRetainable = new CRetainable(); this._loadingUIRetainable.IsRetainedRx.Subscribe(retained => { if (retained) { this._loadingCanvas.ShowLoadingUI(); } else { this._loadingCanvas.HideLoadingUI(); } }) .AddTo(this._disposables); CApplication.QuittingEvent += () => { this._disposables?.Dispose(); }; }
private static void InitializeBeforeSceneLoad() { Debug.Log($"{nameof(CApplication)} Initializing Application."); // app quit IsQuitting = false; Application.quitting -= QuittingEvent; Application.quitting += QuittingEvent; Application.quitting += () => { Debug.Log("<color=red>CApplication is quitting...</color>"); IsQuitting = true; QuittingCancellationTokenSource?.Cancel(); }; #if Rewired CAssets.LoadAndInstantiateGameObject("Rewired Input Manager"); #endif InitializeDependencyContainerAndBinds(); InitializeApplicationAsync().CAwait(); }
public CCharacterBase InstantiateAndAssignCharacter(string key) { if (key.CIsNullOrEmpty()) { Debug.LogWarning($"Created player {this.PlayerNumber} with no controlling character because '{nameof(key)}' is null or its RuntimeKey is invalid."); return(null); } var character = CAssets.LoadAndInstantiate <CCharacterBase>(key); if (character == null) { Debug.LogError($"Asset key '{key}' gameobject doesnt have a {nameof(CCharacterBase)} component on it! could not create player!"); return(null); } var entryPoint = CSceneEntryPoint.GetSceneEntryPointTransform(0); if (entryPoint != null) { Debug.Log($"Setting '{character.name}' to entryPoint number'{0}'", entryPoint.gameObject); character.TeleportToLocation(entryPoint.transform.position, entryPoint.transform.rotation); Physics.SyncTransforms(); } character.gameObject.SetActive(false); character.name = $"[Character] {character.name}"; this.AddControllingCharacter(character); character.gameObject.SetActive(true); this.CheckIfNeedToCreateCamera(); Debug.Log($"Created player {this.PlayerNumber} controlling character '{character.name}'.", character); return(character); }