public static void DrawComponents(IEntity entity)
        {
            var unfoldedComponents    = GetUnfoldedComponents(entity);
            var componentMemberSearch = GetComponentMemberSearch(entity);

            EditorGUILayoutTools.BeginVerticalBox();

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Components (" + entity.GetComponents().Length + ")", EditorStyles.boldLabel);
                if (EditorGUILayoutTools.MiniButtonLeft("▸"))
                {
                    for (var i = 0; i < unfoldedComponents.Length; i++)
                    {
                        unfoldedComponents[i] = false;
                    }
                }

                if (EditorGUILayoutTools.MiniButtonRight("▾"))
                {
                    for (var i = 0; i < unfoldedComponents.Length; i++)
                    {
                        unfoldedComponents[i] = true;
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            var index = DrawAddComponentMenu(entity);

            if (index >= 0)
            {
                var componentType = entity.ContextInfo.componentTypes[index];
                var component     = entity.CreateComponent(index, componentType);
                entity.AddComponent(index, component);
            }

            EditorGUILayout.Space();

            ComponentNameSearchString = EditorGUILayoutTools.SearchTextField(ComponentNameSearchString);

            EditorGUILayout.Space();

            var indices    = entity.GetComponentIndices();
            var components = entity.GetComponents();

            for (var i = 0; i < components.Length; i++)
            {
                DrawComponent(
                    unfoldedComponents,
                    componentMemberSearch,
                    entity,
                    indices[i],
                    components[i]);
            }

            EditorGUILayoutTools.EndVerticalBox();
        }
        public static void DrawEntity(IEntity entity)
        {
            var bgColor = GUI.backgroundColor;

            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("Destroy Entity"))
            {
                entity.Destroy();
            }

            GUI.backgroundColor = bgColor;

            DrawComponents(entity);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Retained by (" + entity.RetainCount + ")", EditorStyles.boldLabel);

            if (entity.AERC is SafeAERC safeAerc)
            {
                EditorGUILayoutTools.BeginVerticalBox();
                {
                    foreach (var owner in safeAerc.Owners.OrderBy(o => o.GetType().Name))
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField(owner.ToString());
                            if (EditorGUILayoutTools.MiniButton("Release"))
                            {
                                entity.Release(owner);
                            }

                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }
                EditorGUILayoutTools.EndVerticalBox();
            }
        }