Exemplo n.º 1
0
 public static string GetTerrainMeshExportDirectory(GaiaSession gaiaSession = null)
 {
     if (gaiaSession == null)
     {
         gaiaSession = GaiaSessionManager.GetSessionManager().m_session;
     }
     return(CreatePathIfDoesNotExist(GetExportDirectory(gaiaSession) + TERRAIN_MESH_EXPORT_DIRECTORY));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Returns the path to store terrain layer files in
 /// </summary>
 /// <param name="gaiaSession">The current session to get / create this directory for</param>
 /// <returns></returns>
 public static string GetTerrainLayerPath(GaiaSession gaiaSession = null)
 {
     if (gaiaSession == null)
     {
         gaiaSession = GaiaSessionManager.GetSessionManager().m_session;
     }
     return(CreatePathIfDoesNotExist(GetScenePath(gaiaSession) + TERRAIN_LAYERS_DIRECTORY));
 }
Exemplo n.º 3
0
 public static string GetMaskMapExportDirectory(GaiaSession gaiaSession = null)
 {
     if (gaiaSession == null)
     {
         gaiaSession = GaiaSessionManager.GetSessionManager().m_session;
     }
     return(CreatePathIfDoesNotExist(GetExportDirectory(gaiaSession) + MASK_MAP_EXPORT_DIRECTORY));
 }
Exemplo n.º 4
0
        public static string GetSceneProfilesFolderPath(GaiaSession gaiaSession, bool create = true)
        {
#if UNITY_EDITOR
            return(CreatePathIfDoesNotExist(GetSessionSubFolderPath(gaiaSession, create) + SESSION_SCENE_PROFILE_DIRECTORY));
#else
            return("");
#endif
        }
Exemplo n.º 5
0
 /// <summary>
 /// Returns the path to store scene files in, according to the Gaia Session path
 /// </summary>
 /// <param name="gaiaSession">The session to get / create the directory for</param>
 /// <returns></returns>
 public static string GetScenePath(GaiaSession gaiaSession = null)
 {
     if (gaiaSession == null)
     {
         gaiaSession = GaiaSessionManager.GetSessionManager().m_session;
     }
     return(GetSessionSubFolderPath(gaiaSession));
 }
Exemplo n.º 6
0
        /// <summary>
        /// Returns a path to store scriptable object data for the session operations.
        /// </summary>
        /// <param name="gaiaSession">The session to create the directory for</param>
        /// <returns></returns>
        public static string GetSessionOperationPath(GaiaSession gaiaSession, bool create = true)
        {
#if UNITY_EDITOR
            return(CreatePathIfDoesNotExist(GetSessionSubFolderPath(gaiaSession, create) + SESSION_OPERATIONS_DIRECTORY));
#else
            return("");
#endif
        }
Exemplo n.º 7
0
 /// <summary>
 /// Returns the path to store impostor scenes in, according to the session filename
 /// </summary>
 /// <param name="gaiaSession">The session to get / create this path for</param>
 /// <returns></returns>
 public static string GetBackupScenePath(GaiaSession gaiaSession = null)
 {
     if (gaiaSession == null)
     {
         gaiaSession = GaiaSessionManager.GetSessionManager().m_session;
     }
     return(CreatePathIfDoesNotExist(GetScenePath(gaiaSession) + BACKUP_SCENES_DIRECTORY));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Returns the path to store collider scenes in, according to the session filename
 /// </summary>
 /// <param name="gaiaSession">The session to get / create this path for</param>
 /// <returns></returns>
 public static string GetColliderScenePath(GaiaSession gaiaSession = null)
 {
     if (gaiaSession == null)
     {
         gaiaSession = GaiaSessionManager.GetSessionManager().m_session;
     }
     return(CreatePathIfDoesNotExist(GetScenePath(gaiaSession) + COLLIDER_SCENES_DIRECTORY));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Returns the path to store impostor scenes in, according to the session filename
 /// </summary>
 /// <param name="gaiaSession">The session to get / create this path for</param>
 /// <returns></returns>
 public static string GetImpostorScenePath(GaiaSession gaiaSession = null)
 {
     if (gaiaSession == null)
     {
         gaiaSession = GaiaSessionManager.GetSessionManager().m_session;
     }
     return(CreatePathIfDoesNotExist(GetScenePath(gaiaSession) + IMPOSTOR_SCENES_DIRECTORY));
 }
Exemplo n.º 10
0
        void OnEnable()
        {
            //Get the settings and update tooltips
            GaiaSettings settings = Gaia.Utils.GetGaiaSettings();

            if (settings != null)
            {
                m_showTooltips = settings.m_showTooltips;
            }

            //Get our resource
            m_session = (GaiaSession)target;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Returns a folder that is named as the session asset, to store session related data into.
        /// </summary>
        /// <param name="gaiaSession">The session to create the directory for</param>
        /// <returns></returns>
        public static string GetSessionSubFolderPath(GaiaSession gaiaSession, bool create = true)
        {
#if UNITY_EDITOR
            string masterScenePath = AssetDatabase.GetAssetPath(gaiaSession).Replace(".asset", "");
            if (String.IsNullOrEmpty(masterScenePath))
            {
                GaiaSessionManager gsm = GaiaSessionManager.GetSessionManager(false);
                gsm.SaveSession();
                masterScenePath = AssetDatabase.GetAssetPath(gsm.m_session).Replace(".asset", "");
            }
            if (create)
            {
                return(CreatePathIfDoesNotExist(masterScenePath));
            }
            else
            {
                return(masterScenePath);
            }
#else
            return("");
#endif
        }
Exemplo n.º 12
0
        public override void OnInspectorGUI()
        {
            //Get our resource
            m_session = (GaiaSession)target;

            //Set up the box style
            if (m_boxStyle == null)
            {
                m_boxStyle = new GUIStyle(GUI.skin.box);
                m_boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
                m_boxStyle.fontStyle        = FontStyle.Bold;
                m_boxStyle.alignment        = TextAnchor.UpperLeft;
            }

            //Setup the wrap style
            if (m_wrapStyle == null)
            {
                m_wrapStyle          = new GUIStyle(GUI.skin.label);
                m_wrapStyle.wordWrap = true;
            }

            //Set up the description wrap style
            if (m_descWrapStyle == null)
            {
                m_descWrapStyle          = new GUIStyle(GUI.skin.textArea);
                m_descWrapStyle.wordWrap = true;
            }

            //Create a nice text intro
            GUILayout.BeginVertical("Gaia Session", m_boxStyle);
            GUILayout.Space(20);
            EditorGUILayout.LabelField("Contains the data used to backup, share and play back sessions. Use the session manager to view, edit or play back sessions.", m_wrapStyle);
            GUILayout.Space(4);
            GUILayout.EndVertical();

            //Make some space
            GUILayout.Space(4);

            //Wrap it up in a box
            GUILayout.BeginVertical(m_boxStyle);
            GUILayout.BeginVertical("Summary:", m_boxStyle);
            GUILayout.Space(20);

            //Display the basic details
            EditorGUILayout.LabelField("Name", m_session.m_name);
            EditorGUILayout.LabelField("Description", m_session.m_description, m_wrapStyle);
            EditorGUILayout.LabelField("Created", m_session.m_dateCreated);
            EditorGUILayout.LabelField("Dimensions", string.Format("w{0} d{1} h{2} meters", m_session.m_terrainWidth, m_session.m_terrainDepth, m_session.m_terrainHeight));
            EditorGUILayout.LabelField("Sea Level", string.Format("{0} meters", m_session.m_seaLevel));
            EditorGUILayout.LabelField("Locked", m_session.m_isLocked.ToString());

            Texture2D previewImage = m_session.GetPreviewImage();

            if (previewImage != null)
            {
                //Get aspect ratio and available space and display the image
                float width  = Screen.width - 43f;
                float height = previewImage.height * (width / previewImage.width);
                GUILayout.Label(previewImage, GUILayout.MaxWidth(width), GUILayout.MaxHeight(height));
            }

            GUILayout.EndVertical();

            //Iterate through the operations
            GUILayout.BeginVertical("Operations:", m_boxStyle);
            GUILayout.Space(20);

            if (m_session.m_operations.Count == 0)
            {
                GUILayout.Space(5);
                GUILayout.Label("No operations yet...");
                GUILayout.Space(5);
            }
            else
            {
                GaiaOperation op;
                EditorGUI.indentLevel++;
                for (int opIdx = 0; opIdx < m_session.m_operations.Count; opIdx++)
                {
                    op = m_session.m_operations[opIdx];

                    if (op.m_isActive)
                    {
                        op.m_isFoldedOut = EditorGUILayout.Foldout(op.m_isFoldedOut, op.m_description);
                    }
                    else
                    {
                        op.m_isFoldedOut = EditorGUILayout.Foldout(op.m_isFoldedOut, op.m_description + " [inactive]");
                    }

                    if (op.m_isFoldedOut)
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.LabelField("Description", op.m_description, m_wrapStyle);
                        EditorGUILayout.LabelField("Created", op.m_operationDateTime);
                        EditorGUILayout.LabelField("Active", op.m_isActive.ToString());
                        EditorGUI.indentLevel--;
                    }
                }
                EditorGUI.indentLevel--;
            }
            GUILayout.EndVertical();
            GUILayout.EndVertical();
        }
Exemplo n.º 13
0
        public override void OnInspectorGUI()
        {
            //Get our resource
            m_session = (GaiaSession)target;

            //Set up the box style
            if (m_boxStyle == null)
            {
                m_boxStyle = new GUIStyle(GUI.skin.box);
                m_boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
                m_boxStyle.fontStyle        = FontStyle.Bold;
                m_boxStyle.alignment        = TextAnchor.UpperLeft;
            }

            //Setup the wrap style
            if (m_wrapStyle == null)
            {
                m_wrapStyle          = new GUIStyle(GUI.skin.label);
                m_wrapStyle.wordWrap = true;
            }

            //Set up the description wrap style
            if (m_descWrapStyle == null)
            {
                m_descWrapStyle          = new GUIStyle(GUI.skin.textArea);
                m_descWrapStyle.wordWrap = true;
            }

            //Create a nice text intro
            GUILayout.BeginVertical("Gaia Session", m_boxStyle);
            GUILayout.Space(20);
            EditorGUILayout.LabelField("Contains the data used to backup, share and play back sessions. Use the session manager to view, edit or play back sessions.", m_wrapStyle);
            GUILayout.Space(4);
            GUILayout.EndVertical();

            //Make some space
            GUILayout.Space(4);

            //Wrap it up in a box
            GUILayout.BeginVertical(m_boxStyle);
            GUILayout.BeginVertical("Summary:", m_boxStyle);
            GUILayout.Space(20);

            //Display the basic details
            EditorGUILayout.LabelField("Name", m_session.m_name);
            EditorGUILayout.LabelField("Description", m_session.m_description, m_wrapStyle);
            EditorGUILayout.LabelField("Created", m_session.m_dateCreated);
            EditorGUILayout.LabelField("Dimensions", string.Format("w{0} d{1} h{2} meters", m_session.m_terrainWidth, m_session.m_terrainDepth, m_session.m_terrainHeight));
            EditorGUILayout.LabelField("Sea Level", string.Format("{0} meters", m_session.m_seaLevel));
            EditorGUILayout.LabelField("Locked", m_session.m_isLocked.ToString());

            Texture2D previewImage = m_session.m_previewImage;

            if (previewImage != null)
            {
                //Get aspect ratio and available space and display the image
                float width  = Screen.width - 43f;
                float height = previewImage.height * (width / previewImage.width);
                GUILayout.Label(previewImage, GUILayout.MaxWidth(width), GUILayout.MaxHeight(height));
            }

            GUILayout.EndVertical();

            //Iterate through the operations
            GUILayout.BeginVertical("Operations:", m_boxStyle);
            GUILayout.Space(20);

            if (m_session.m_operations.Count == 0)
            {
                GUILayout.Space(5);
                GUILayout.Label("No operations yet...");
                GUILayout.Space(5);
            }
            else
            {
                GaiaOperation op;
                EditorGUI.indentLevel++;
                for (int opIdx = 0; opIdx < m_session.m_operations.Count; opIdx++)
                {
                    op = m_session.m_operations[opIdx];

                    if (op.m_isActive)
                    {
                        op.m_isFoldedOut = EditorGUILayout.Foldout(op.m_isFoldedOut, op.m_description, true);
                    }
                    else
                    {
                        op.m_isFoldedOut = EditorGUILayout.Foldout(op.m_isFoldedOut, op.m_description + " [inactive]", true);
                    }

                    if (op.m_isFoldedOut)
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.LabelField("Description", op.m_description, m_wrapStyle);
                        EditorGUILayout.LabelField("Created", op.m_operationDateTime);
                        EditorGUILayout.LabelField("Active", op.m_isActive.ToString());
                        EditorGUI.indentLevel--;
                    }
                }
                EditorGUI.indentLevel--;
            }
            GUILayout.EndVertical();
            GUILayout.EndVertical();
            if (GUILayout.Button("Play Session"))
            {
                GaiaSessionManager gsm = GaiaSessionManager.GetSessionManager(false, false);
                if (gsm == null)
                {
                    GameObject gaiaObj = GaiaUtils.GetGaiaGameObject();
                    GameObject mgrObj  = new GameObject("Session Manager");
                    gsm = mgrObj.AddComponent <GaiaSessionManager>();
                    mgrObj.transform.parent = gaiaObj.transform;
                }


                GaiaLighting.SetDefaultAmbientLight(GaiaUtils.GetGaiaSettings().m_gaiaLightingProfile);
                //make a copy of the session - otherwise there is the danger of conflicting with the old session data while playing back the session
                GaiaSession sessionCopy = Instantiate(m_session);
                sessionCopy.m_name = GaiaSessionManager.GetNewSessionName();
                sessionCopy.name   = sessionCopy.m_name;
                gsm.m_session      = sessionCopy;
                string path = GaiaDirectories.GetSessionDirectory();
                AssetDatabase.CreateAsset(sessionCopy, path + "/" + sessionCopy.m_name + ".asset");
                AssetDatabase.SaveAssets();
                GaiaSessionManager.PlaySession(sessionCopy);
            }

            if (GUILayout.Button("Open Session in Manager"))
            {
                GaiaSessionManager.LoadSession(m_session);
            }
        }