/// <summary>
        /// Draws the body GUI section
        /// </summary>
        /// <param name="settings"></param>
        public virtual void DrawContent(GenesisSettings settings)
        {
            // The default implementation for draw content enables its content to be collapsed via a foldout header bar.
            _drawContent = EditorGUILayoutTools.DrawSectionHeaderToggle(Title, _drawContent);
            if (!_drawContent)
            {
                return;
            }

            EditorGUILayoutTools.BeginSectionContent();
            DrawContentBody(settings);
            EditorGUILayoutTools.EndSectionContent();
        }
Exemple #2
0
        public override void OnInspectorGUI()
        {
            var contextObserver = ((ContextObserverBehaviour)target).ContextObserver;

            EditorGUILayoutTools.BeginSectionContent();
            {
                EditorGUILayout.LabelField(contextObserver.Context.ContextInfo.name, EditorStyles.boldLabel);
                EditorGUILayout.LabelField("Entities", contextObserver.Context.Count.ToString());
                EditorGUILayout.LabelField("Reusable entities", contextObserver.Context.ReusableEntitiesCount.ToString());

                var retainedEntitiesCount = contextObserver.Context.RetainedEntitiesCount;
                if (retainedEntitiesCount != 0)
                {
                    var c = GUI.color;
                    GUI.color = Color.red;
                    EditorGUILayout.LabelField("Retained entities", retainedEntitiesCount.ToString());
                    GUI.color = c;
                    EditorGUILayout.HelpBox(
                        "WARNING: There are retained entities.\nDid you call entity.Retain(owner) and forgot to call entity.Release(owner)?",
                        MessageType.Warning);
                }

                EditorGUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("Create Entity"))
                    {
                        var entity          = contextObserver.Context.CreateEntity();
                        var entityBehaviour = FindObjectsOfType <EntityBehaviour>()
                                              .Single(eb => eb.Entity == entity);

                        Selection.activeGameObject = entityBehaviour.gameObject;
                    }

                    var bgColor = GUI.backgroundColor;
                    GUI.backgroundColor = Color.red;
                    if (GUILayout.Button("Destroy All Entities"))
                    {
                        contextObserver.Context.DestroyAllEntities();
                    }

                    GUI.backgroundColor = bgColor;
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayoutTools.EndSectionContent();

            var groups = contextObserver.Groups;

            if (groups.Length != 0)
            {
                EditorGUILayoutTools.BeginSectionContent();
                {
                    EditorGUILayout.LabelField("Groups (" + groups.Length + ")", EditorStyles.boldLabel);
                    foreach (var group in groups.OrderByDescending(g => g.Count))
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField(group.ToString());
                            EditorGUILayout.LabelField(group.Count.ToString(), GUILayout.Width(48));
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
                EditorGUILayoutTools.EndSectionContent();
            }

            EditorUtility.SetDirty(target);
        }