public static int LoadScene( string filePath, AGF_LevelLoader.LoadSceneMode mode = AGF_LevelLoader.LoadSceneMode.All, string overrideUserDataHomeFolder = "" ) { if(GameObject.Find("Directional Light")) DestroyImmediate(GameObject.Find("Directional Light")); int returnCode = AGF_ReturnCode.Success; m_LoadSceneMode = mode; GameObject parentObject = null; if (m_LoadSceneMode == AGF_LevelLoader.LoadSceneMode.All) { parentObject = new GameObject(); parentObject.name = Path.GetFileNameWithoutExtension (filePath); } // Get the position of the integration window. Rect integrationWindowRect = AGF_IntegrationWindow.window.position; AGF_EditorSceneLoader window = GetWindowWithRect<AGF_EditorSceneLoader>( new Rect( integrationWindowRect.x + integrationWindowRect.width/2.0f, integrationWindowRect.y + integrationWindowRect.height/2.0f, 1.0f, 1.0f ) ); window.position = new Rect( integrationWindowRect.x + integrationWindowRect.width/2.0f, integrationWindowRect.y + integrationWindowRect.height/2.0f, 1.0f, 1.0f ); // Check that the integration prefab has all necessary components. if ( GameObject.Find ("AGF_LevelLoader") == null || GameObject.Find ("EventHandler") == null || GameObject.Find ("AGF_LevelLoader") == null || GameObject.Find ("AGF_AtmosphereManager") == null || GameObject.Find ("AGF_TileListManager") == null || GameObject.Find ("AGF_TerrainManager") == null || GameObject.Find ("AGF_GibManager") == null || GameObject.Find ("AGF_GridManager") == null ){ window.CloseWindow(); return AGF_ReturnCode.AGFIntegrationPrefabComponentMissing; } m_LevelLoader = GameObject.Find ("AGF_LevelLoader").GetComponent<AGF_LevelLoader>(); // step 2: Init all gameobjects. (Most of these will simply call the Start() methods of the given object.) GameObject.Find ("EventHandler").GetComponent<EventHandler>().EditorInit(); GameObject.Find ("AGF_LevelLoader").GetComponent<AGF_LevelLoader>().EditorInit(); GameObject.Find ("AGF_AtmosphereManager").GetComponent<AGF_AtmosphereManager>().EditorInit(); GameObject.Find ("AGF_TileListManager").GetComponent<AGF_TileListManager>().EditorInit(); GameObject.Find ("AGF_TerrainManager").GetComponent<AGF_TerrainManager>().EditorInit(parentObject); GameObject.Find ("AGF_GibManager").GetComponent<AGF_GibManager>().EditorInit(); GameObject.Find ("AGF_GridManager").GetComponent<AGF_GridManager>().EditorInit(); // step 3: loading the scene is now possible through the level loader. returnCode = m_LevelLoader.LoadScene( filePath, mode, overrideUserDataHomeFolder ); if ( returnCode != AGF_ReturnCode.Success ){ window.CloseWindow(); return returnCode; } // step 4: wait for an event callback to be received. m_CurrentSubState = SubState.LoadingScene; return returnCode; }
public SkyboxProperties() : base() { // store references m_TerrainManager = GameObject.Find ("AGF_TerrainManager").GetComponent<AGF_TerrainManager>(); m_SaveDataManager = GameObject.Find ("AGF_LevelLoader").GetComponent<AGF_LevelLoader>(); m_CameraManager = GameObject.Find ("AGF_CameraManager").GetComponent<AGF_CameraManager>(); }
private static void DisplaySceneImport( ref float currentHeight, string title, string description, AGF_LevelLoader.LoadSceneMode mode, IntegrationType currentIntegrationType ){ Rect thisRect = window.position; Color prevColor = GUI.color; // Title Text DisplayCenteredText( ref currentHeight, 15, title ); // Description Text DisplayWordWrappedCenteredText( ref currentHeight, 11, description, 400.0f ); float buttonWidth = 200.0f, buttonHeight = 20.0f; // step 1: instantiate integration prefab. GameObject agfIntegration = GameObject.Find ("AGF_Integration"); EditorGUI.HelpBox( new Rect( 20.0f, currentHeight, thisRect.width - (20.0f * 2.0f), 20.0f ), "Step 1: Instantiate the integration prefab.", MessageType.Info ); GUI.Toggle( new Rect( thisRect.width - 40.0f, currentHeight, 20.0f, 20.0f ), agfIntegration != null, "" ); currentHeight += 30.0f; if ( agfIntegration != null ){ GUI.color = Color.grey; } if ( GUI.Button ( new Rect( thisRect.width/2.0f - buttonWidth/2.0f, currentHeight, buttonWidth, buttonHeight ), "Instantiate Prefab" ) ){ if ( GUI.color != Color.grey ){ string path = "Assets/AGF_SceneLoader/AGF_Assets/Prefabs/AGF_Integration.prefab"; GameObject integrationPrefab = (GameObject)MonoBehaviour.Instantiate( (GameObject)AssetDatabase.LoadAssetAtPath( path, typeof(GameObject) ) ); integrationPrefab.name = "AGF_Integration"; } } GUI.color = prevColor; currentHeight += 32.0f; // step 2: Assign the camera link. GameObject cameraManager = GameObject.Find ("AGF_CameraManager"); bool isCameraConfigured = (cameraManager != null && IsCameraConfigured( cameraManager.GetComponent<AGF_CameraManager>().mainCamera ) ); EditorGUI.HelpBox( new Rect( 20.0f, currentHeight, thisRect.width - (20.0f * 2.0f), 20.0f ), "Step 2: Ensure that the main camera is properly configured.", MessageType.Info ); GUI.Toggle( new Rect( thisRect.width - 40.0f, currentHeight, 20.0f, 20.0f ), isCameraConfigured, "" ); currentHeight += 30.0f; DisplayCameraConfiguration( ref currentHeight ); // step 3: Load the scene if ( mode == AGF_LevelLoader.LoadSceneMode.All && currentIntegrationType == IntegrationType.Geovox){ EditorGUI.HelpBox( new Rect( 20.0f, currentHeight, thisRect.width - (20.0f * 2.0f), 20.0f ), "Step 3: Load the Geovox scene. The integration prefab will be destroyed.", MessageType.Info ); currentHeight += 30.0f; if ( GUI.Button ( new Rect( thisRect.width/2.0f - buttonWidth/2.0f, currentHeight, buttonWidth, buttonHeight ), "Load Geovox Scene" ) ){ int returnCode = LoadGeovoxScene(); if ( returnCode != AGF_ReturnCode.Success ){ Debug.LogError(returnCode); HandleLoadSceneError( returnCode ); } } } else if ( mode == AGF_LevelLoader.LoadSceneMode.CameraOnly ){ string integrationPrefix = currentIntegrationType.ToString(); EditorGUI.HelpBox( new Rect( 20.0f, currentHeight, thisRect.width - (20.0f * 2.0f), 30.0f ), "Step 3: Load the camera settings from an " + integrationPrefix +" scene. The integration prefab will be destroyed.", MessageType.Info ); currentHeight += 40.0f; if ( isCameraConfigured == false ){ GUI.color = Color.grey; } if ( GUI.Button ( new Rect( thisRect.width/2.0f - 250.0f/2.0f, currentHeight, 250.0f, buttonHeight ), "Load Camera Settings from " + integrationPrefix +" Scene" ) ){ if ( GUI.color != Color.grey ){ int returnCode = LoadCameraFromScene(); if ( returnCode != AGF_ReturnCode.Success ){ Debug.LogError(returnCode); HandleLoadSceneError( returnCode ); } } } } GUI.color = prevColor; currentHeight += 32.0f; }