public void OnAwake() { ClearVariables(); // Test for key imports References references = (References)Resources.Load(Resource.references); if (references) { SceneManager sceneManager = AdvGame.GetReferences().sceneManager; SettingsManager settingsManager = AdvGame.GetReferences().settingsManager; ActionsManager actionsManager = AdvGame.GetReferences().actionsManager; InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; SpeechManager speechManager = AdvGame.GetReferences().speechManager; CursorManager cursorManager = AdvGame.GetReferences().cursorManager; MenuManager menuManager = AdvGame.GetReferences().menuManager; if (sceneManager == null) { ACDebug.LogError("No Scene Manager found - please set one using the Adventure Creator Kit wizard"); } if (settingsManager == null) { ACDebug.LogError("No Settings Manager found - please set one using the Adventure Creator Kit wizard"); } else { if (settingsManager.IsInLoadingScene()) { ACDebug.Log("Bypassing regular AC startup because the current scene is the 'Loading' scene."); SetPersistentEngine(); return; } // Unity 5.3 has a bug whereby a modified Player prefab is placed in the scene when editing, but not visible // This causes the Player to not load properly, so try to detect this remnant and delete it! GameObject existingPlayer = GameObject.FindGameObjectWithTag(Tags.player); if (existingPlayer != null) { if (settingsManager.GetDefaultPlayer() != null && existingPlayer.name == (settingsManager.GetDefaultPlayer().name + "(Clone)")) { DestroyImmediate(GameObject.FindGameObjectWithTag(Tags.player)); ACDebug.LogWarning("Player clone found in scene - this may have been hidden by a Unity bug, and has been destroyed."); } } if (!GameObject.FindGameObjectWithTag(Tags.player)) { KickStarter.ResetPlayer(settingsManager.GetDefaultPlayer(), settingsManager.GetDefaultPlayerID(), false, Quaternion.identity); } else { KickStarter.playerPrefab = GameObject.FindWithTag(Tags.player).GetComponent <Player>(); if (sceneChanger == null || sceneChanger.GetPlayerOnTransition() == null) { // New local player if (KickStarter.playerPrefab != null) { KickStarter.playerPrefab.Initialise(); } } AssignLocalPlayer(); } } if (actionsManager == null) { ACDebug.LogError("No Actions Manager found - please set one using the main Adventure Creator window"); } if (inventoryManager == null) { ACDebug.LogError("No Inventory Manager found - please set one using the main Adventure Creator window"); } if (variablesManager == null) { ACDebug.LogError("No Variables Manager found - please set one using the main Adventure Creator window"); } if (speechManager == null) { ACDebug.LogError("No Speech Manager found - please set one using the main Adventure Creator window"); } if (cursorManager == null) { ACDebug.LogError("No Cursor Manager found - please set one using the main Adventure Creator window"); } if (menuManager == null) { ACDebug.LogError("No Menu Manager found - please set one using the main Adventure Creator window"); } if (GameObject.FindWithTag(Tags.player) == null && KickStarter.settingsManager.movementMethod != MovementMethod.None) { ACDebug.LogWarning("No Player found - please set one using the Settings Manager, tagging it as Player and placing it in a Resources folder"); } } else { ACDebug.LogError("No References object found. Please set one using the main Adventure Creator window"); } SetPersistentEngine(); if (persistentEnginePrefab == null) { ACDebug.LogError("No PersistentEngine prefab found - please place one in the Resources directory, and tag it as PersistentEngine"); } else { if (persistentEnginePrefab.GetComponent <Options>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no Options component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeInventory>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeInventory component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeVariables>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeVariables component attached."); } if (persistentEnginePrefab.GetComponent <PlayerMenus>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no PlayerMenus component attached."); } if (persistentEnginePrefab.GetComponent <StateHandler>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no StateHandler component attached."); } if (persistentEnginePrefab.GetComponent <SceneChanger>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no SceneChanger component attached."); } if (persistentEnginePrefab.GetComponent <SaveSystem>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no SaveSystem component attached."); } if (persistentEnginePrefab.GetComponent <LevelStorage>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no LevelStorage component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeLanguages>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeLanguages component attached."); } if (persistentEnginePrefab.GetComponent <ActionListAssetManager>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no ActionListAssetManager component attached."); } } if (this.GetComponent <MenuSystem>() == null) { ACDebug.LogError(this.name + " has no MenuSystem component attached."); } if (this.GetComponent <Dialog>() == null) { ACDebug.LogError(this.name + " has no Dialog component attached."); } if (this.GetComponent <PlayerInput>() == null) { ACDebug.LogError(this.name + " has no PlayerInput component attached."); } if (this.GetComponent <PlayerInteraction>() == null) { ACDebug.LogError(this.name + " has no PlayerInteraction component attached."); } if (this.GetComponent <PlayerMovement>() == null) { ACDebug.LogError(this.name + " has no PlayerMovement component attached."); } if (this.GetComponent <PlayerCursor>() == null) { ACDebug.LogError(this.name + " has no PlayerCursor component attached."); } if (this.GetComponent <PlayerQTE>() == null) { ACDebug.LogError(this.name + " has no PlayerQTE component attached."); } if (this.GetComponent <SceneSettings>() == null) { ACDebug.LogError(this.name + " has no SceneSettings component attached."); } else { if (this.GetComponent <SceneSettings>().navigationMethod == AC_NavigationMethod.meshCollider && this.GetComponent <SceneSettings>().navMesh == null) { // No NavMesh, are there Characters in the scene? AC.Char[] allChars = GameObject.FindObjectsOfType(typeof(AC.Char)) as AC.Char[]; if (allChars.Length > 0) { ACDebug.LogWarning("No NavMesh set. Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager."); } } if (this.GetComponent <SceneSettings>().defaultPlayerStart == null) { if (AdvGame.GetReferences().settingsManager == null || AdvGame.GetReferences().settingsManager.GetDefaultPlayer() != null) { ACDebug.LogWarning("No default PlayerStart set. The game may not be able to begin if one is not defined - please choose one using the Scene Manager."); } } } if (this.GetComponent <NavigationManager>() == null) { ACDebug.LogError(this.name + " has no NavigationManager component attached."); } if (this.GetComponent <ActionListManager>() == null) { ACDebug.LogError(this.name + " has no ActionListManager component attached."); } if (this.GetComponent <EventManager>() == null) { ACDebug.LogError(this.name + " has no EventManager component attached."); } }
private void Awake() { // Test for key imports References references = (References)Resources.Load(Resource.references); if (references) { SceneManager sceneManager = AdvGame.GetReferences().sceneManager; SettingsManager settingsManager = AdvGame.GetReferences().settingsManager; ActionsManager actionsManager = AdvGame.GetReferences().actionsManager; InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; SpeechManager speechManager = AdvGame.GetReferences().speechManager; CursorManager cursorManager = AdvGame.GetReferences().cursorManager; MenuManager menuManager = AdvGame.GetReferences().menuManager; if (sceneManager == null) { Debug.LogError("No Scene Manager found - please set one using the Adventure Creator Kit wizard"); } if (settingsManager == null) { Debug.LogError("No Settings Manager found - please set one using the Adventure Creator Kit wizard"); } else { if (settingsManager.IsInLoadingScene()) { Debug.Log("Bypassing regular AC startup because the current scene is the 'Loading' scene."); return; } if (!GameObject.FindGameObjectWithTag(Tags.player)) { KickStarter.ResetPlayer(settingsManager.GetDefaultPlayer(), settingsManager.GetDefaultPlayerID(), false, Quaternion.identity); } else { KickStarter.playerPrefab = GameObject.FindWithTag(Tags.player).GetComponent <Player>(); if (sceneChanger != null && sceneChanger.GetPlayerOnTransition() != null && settingsManager.playerSwitching == PlayerSwitching.DoNotAllow) { // Replace "prefab" player with a local one if one exists GameObject[] playerObs = GameObject.FindGameObjectsWithTag(Tags.player); foreach (GameObject playerOb in playerObs) { if (playerOb.GetComponent <Player>() && sceneChanger.GetPlayerOnTransition() != playerOb.GetComponent <Player>()) { KickStarter.sceneChanger.DestroyOldPlayer(); KickStarter.playerPrefab = playerOb.GetComponent <Player>(); break; } } } } } if (actionsManager == null) { Debug.LogError("No Actions Manager found - please set one using the main Adventure Creator window"); } if (inventoryManager == null) { Debug.LogError("No Inventory Manager found - please set one using the main Adventure Creator window"); } if (variablesManager == null) { Debug.LogError("No Variables Manager found - please set one using the main Adventure Creator window"); } if (speechManager == null) { Debug.LogError("No Speech Manager found - please set one using the main Adventure Creator window"); } if (cursorManager == null) { Debug.LogError("No Cursor Manager found - please set one using the main Adventure Creator window"); } if (menuManager == null) { Debug.LogError("No Menu Manager found - please set one using the main Adventure Creator window"); } if (GameObject.FindWithTag(Tags.player) == null && KickStarter.settingsManager.movementMethod != MovementMethod.None) { Debug.LogWarning("No Player found - please set one using the Settings Manager, tagging it as Player and placing it in a Resources folder"); } } else { Debug.LogError("No References object found. Please set one using the main Adventure Creator window"); } if (persistentEnginePrefab == null) { try { persistentEnginePrefab = (GameObject)Instantiate(Resources.Load(Resource.persistentEngine)); persistentEnginePrefab.name = AdvGame.GetName(Resource.persistentEngine); } catch {} } if (persistentEnginePrefab == null) { Debug.LogError("No PersistentEngine prefab found - please place one in the Resources directory, and tag it as PersistentEngine"); } else { if (persistentEnginePrefab.GetComponent <Options>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no Options component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeInventory>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no RuntimeInventory component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeVariables>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no RuntimeVariables component attached."); } if (persistentEnginePrefab.GetComponent <PlayerMenus>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no PlayerMenus component attached."); } if (persistentEnginePrefab.GetComponent <StateHandler>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no StateHandler component attached."); } if (persistentEnginePrefab.GetComponent <SceneChanger>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no SceneChanger component attached."); } if (persistentEnginePrefab.GetComponent <SaveSystem>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no SaveSystem component attached."); } if (persistentEnginePrefab.GetComponent <LevelStorage>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no LevelStorage component attached."); } } if (GameObject.FindWithTag(Tags.mainCamera) == null) { Debug.LogError("No MainCamera found - please click 'Organise room objects' in the Scene Manager to create one."); } else { if (GameObject.FindWithTag(Tags.mainCamera).GetComponent <MainCamera>() == null) { Debug.LogError("MainCamera has no MainCamera component."); } } if (this.GetComponent <MenuSystem>() == null) { Debug.LogError(this.name + " has no MenuSystem component attached."); } if (this.GetComponent <Dialog>() == null) { Debug.LogError(this.name + " has no Dialog component attached."); } if (this.GetComponent <PlayerInput>() == null) { Debug.LogError(this.name + " has no PlayerInput component attached."); } if (this.GetComponent <PlayerInteraction>() == null) { Debug.LogError(this.name + " has no PlayerInteraction component attached."); } if (this.GetComponent <PlayerMovement>() == null) { Debug.LogError(this.name + " has no PlayerMovement component attached."); } if (this.GetComponent <PlayerCursor>() == null) { Debug.LogError(this.name + " has no PlayerCursor component attached."); } if (this.GetComponent <PlayerQTE>() == null) { Debug.LogError(this.name + " has no PlayerQTE component attached."); } if (this.GetComponent <SceneSettings>() == null) { Debug.LogError(this.name + " has no SceneSettings component attached."); } else { if (this.GetComponent <SceneSettings>().navigationMethod == AC_NavigationMethod.meshCollider && this.GetComponent <SceneSettings>().navMesh == null) { // No NavMesh, are there Characters in the scene? AC.Char[] allChars = GameObject.FindObjectsOfType(typeof(AC.Char)) as AC.Char[]; if (allChars.Length > 0) { Debug.LogWarning("No NavMesh set. Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager."); } } if (this.GetComponent <SceneSettings>().defaultPlayerStart == null) { Debug.LogWarning("No default PlayerStart set. The game may not be able to begin if one is not defined - please choose one using the Scene Manager."); } } if (this.GetComponent <NavigationManager>() == null) { Debug.LogError(this.name + " has no NavigationManager component attached."); } if (this.GetComponent <ActionListManager>() == null) { Debug.LogError(this.name + " has no ActionListManager component attached."); } }