Exemplo n.º 1
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();
        }