Ejemplo n.º 1
0
        public static void DrawFields(object instance, float fieldWidth)
        {
            var padding    = 2f;
            var margin     = 1f;
            var cellHeight = 24f;
            var tableStyle = new GUIStyle("Box");

            GUILayout.BeginHorizontal();
            {
                GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Field", EditorStyles.miniBoldLabel); },
                                 tableStyle, GUILayout.Width(fieldWidth),
                                 GUILayout.Height(cellHeight));
                GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Value", EditorStyles.miniBoldLabel); },
                                 tableStyle, GUILayout.ExpandWidth(true),
                                 GUILayout.Height(cellHeight));
            }
            GUILayout.EndHorizontal();

            var fields = instance.GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);

            foreach (var field in fields)
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(field.Name); }, tableStyle,
                                     GUILayout.Width(fieldWidth), GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => {
                        var value = field.GetValue(instance);
                        if (GUILayoutExt.PropertyField(field, ref value) == true)
                        {
                            field.SetValue(instance, value);
                        }
                    }, tableStyle, GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                }
                GUILayout.EndHorizontal();
            }
        }
        bool IGUIEditorBase.OnDrawGUI()
        {
            var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.label);

            style.richText = true;

            var dataCount = 0;

            foreach (System.Collections.DictionaryEntry ren in this.target.GetData())
            {
                dataCount += ((ME.ECS.Collections.SortedList <long, HistoryEvent>)ren.Value).Count;
            }

            GUILayoutExt.Box(2f, 2f, () => {
                UnityEngine.GUILayout.Label("<b>Memory Usage:</b> " + ME.ECS.MathUtils.BytesCountToString(WorldEditor.current.stateSize * (this.target.GetCacheSize() / this.target.GetTicksPerState())), style);
                UnityEngine.GUILayout.Label("<b>Events:</b> " + dataCount.ToString(), style);
                UnityEngine.GUILayout.Label("<b>Events Added:</b> " + this.target.GetEventsAddedCount().ToString(), style);
                UnityEngine.GUILayout.Label("<b>Events Played:</b> " + this.target.GetEventsPlayedCount().ToString(), style);
            });

            GUILayoutExt.Separator();
            var val = this.syncTableFoldState;

            GUILayoutExt.FoldOut(ref val, "Sync Table", () => {
                const float padding    = 2f;
                const float margin     = 2f;
                const float col1       = 60f;
                const float col2       = 50f;
                const float col3       = 22f;
                const float cellHeight = 22f;
                var tableStyle         = (GUIStyle)"Box";

                GUILayout.BeginHorizontal();
                {
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Tick", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col1),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Player", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col2),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Hash", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.ExpandWidth(true),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption(string.Empty, EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col3),
                                     GUILayout.Height(cellHeight));
                }
                GUILayout.EndHorizontal();

                var syncHashTable = this.target.GetSyncHashTable();

                /*if (syncHashTable.ContainsKey(20) == false) syncHashTable.Add(20, new System.Collections.Generic.Dictionary<int, int>() {
                 *  { 100, 1234 }
                 * });
                 * if (syncHashTable.ContainsKey(100) == false) syncHashTable.Add(100, new System.Collections.Generic.Dictionary<int, int>() {
                 *  { 100, 1902832914 },
                 *  { 101, 1902832914 },
                 *  { 102, 1902832915 },
                 * });
                 * if (syncHashTable.ContainsKey(2000) == false) syncHashTable.Add(2000, new System.Collections.Generic.Dictionary<int, int>() {
                 *  { 100, 2345 }
                 * });*/
                foreach (var item in syncHashTable)
                {
                    var tick      = item.Key;
                    int localHash = 0;

                    GUILayout.BeginHorizontal();
                    {
                        GUILayoutExt.DataLabel(tick.ToString(), GUILayout.Width(col1));
                    }
                    GUILayout.EndHorizontal();
                    var stateHashResult = 0;
                    foreach (var kv in item.Value)
                    {
                        var hash = kv.Value;
                        if (localHash != 0 && localHash != hash)
                        {
                            stateHashResult = -1;
                            break;
                        }
                        else if (localHash != 0)
                        {
                            stateHashResult = 1;
                        }
                        localHash = hash;
                    }

                    foreach (var kv in item.Value)
                    {
                        var playerId = kv.Key;
                        GUILayout.BeginHorizontal();
                        {
                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(string.Empty); }, tableStyle, GUILayout.Width(col1), GUILayout.Height(cellHeight));
                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(playerId.ToString()); }, tableStyle, GUILayout.Width(col2), GUILayout.Height(cellHeight));
                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(kv.Value.ToString()); }, tableStyle, GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                            GUILayoutExt.Box(padding, margin, () => {
                                GUILayout.BeginHorizontal();
                                GUILayout.FlexibleSpace();

                                if (stateHashResult == 1)
                                {
                                    using (new GUILayoutExt.GUIColorUsing(Color.green)) {
                                        GUILayout.Toggle(true, new GUIContent(string.Empty, $"Local hash synced with player #{playerId}."), StatesHistoryModuleEditor.syncBoxStyle);
                                    }
                                }
                                else if (stateHashResult == -1)
                                {
                                    using (new GUILayoutExt.GUIColorUsing(Color.red)) {
                                        GUILayout.Toggle(true, new GUIContent(string.Empty, $"Local hash is not the same as player #{playerId} has, your server must resync that player."), StatesHistoryModuleEditor.syncBoxStyle);
                                    }
                                }
                                else
                                {
                                    using (new GUILayoutExt.GUIColorUsing(Color.yellow)) {
                                        GUILayout.Toggle(false, new GUIContent(string.Empty, $"Local hash is not sync yet with player #{playerId}, current tick is less than remote."), StatesHistoryModuleEditor.syncBoxStyle);
                                    }
                                }

                                GUILayout.FlexibleSpace();
                                GUILayout.EndHorizontal();
                            }, tableStyle, GUILayout.Width(col3), GUILayout.Height(cellHeight));
                        }
                        GUILayout.EndHorizontal();
                    }
                }
            });
            this.syncTableFoldState = val;

            GUILayoutExt.Separator();
            val = this.statesHistoryFoldState;
            GUILayoutExt.FoldOut(ref val, "States History", () => {
                var padding    = 2f;
                var margin     = 2f;
                var col1       = 60f;
                var col2       = 70f;
                var cellHeight = 22f;
                var tableStyle = (GUIStyle)"Box";

                UnityEngine.GUILayout.BeginHorizontal();
                {
                    if (UnityEngine.GUILayout.Button("Entities", UnityEditor.EditorStyles.miniButtonLeft) == true)
                    {
                        var world = Worlds.currentWorld;
                        this.PrintEntities(world.currentState);
                    }

                    if (UnityEngine.GUILayout.Button("Events", UnityEditor.EditorStyles.miniButtonMid) == true)
                    {
                        foreach (System.Collections.DictionaryEntry ren in this.target.GetData())
                        {
                            var entry = (ME.ECS.Collections.SortedList <long, HistoryEvent>)ren.Value;
                            for (int i = 0; i < entry.Count; ++i)
                            {
                                UnityEngine.Debug.Log(entry.GetByIndex(i).ToString());
                            }
                        }
                    }

                    if (UnityEngine.GUILayout.Button("Reset State", UnityEditor.EditorStyles.miniButtonRight) == true)
                    {
                        this.target.RecalculateFromResetState();
                    }
                }
                UnityEngine.GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Tick", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col1),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Hash", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.ExpandWidth(true),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Actions", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col2),
                                     GUILayout.Height(cellHeight));
                }
                GUILayout.EndHorizontal();

                var dataStates = this.target.GetDataStates();
                var entries    = dataStates.GetEntries();
                foreach (var entryData in entries)
                {
                    var entry = entryData as ME.ECS.Network.IStatesHistoryEntry;
                    var state = entry.GetData() as State;
                    UnityEngine.GUILayout.BeginHorizontal();
                    {
                        GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(entry.isEmpty == true ? "-" : state.tick.ToString()); }, tableStyle, GUILayout.Width(col1), GUILayout.Height(cellHeight));
                        GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(entry.isEmpty == true ? "-" : state.GetHash().ToString()); }, tableStyle, GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                        GUILayoutExt.Box(padding, margin, () => {
                            EditorGUI.BeginDisabledGroup(entry.isEmpty == true);
                            if (UnityEngine.GUILayout.Button("Entities") == true)
                            {
                                this.PrintEntities(state);
                            }
                            EditorGUI.EndDisabledGroup();
                        }, tableStyle, GUILayout.Width(col2), GUILayout.Height(cellHeight));
                    }
                    UnityEngine.GUILayout.EndHorizontal();
                }
            });
            this.statesHistoryFoldState = val;
            GUILayoutExt.Separator();

            GUILayoutExt.Separator();
            val = this.eventsFoldState;
            GUILayoutExt.FoldOut(ref val, "Events Table", () => {
                const float padding    = 2f;
                const float margin     = 2f;
                const float col1       = 60f;
                const float col2       = 50f;
                const float cellHeight = 22f;
                var tableStyle         = (GUIStyle)"Box";

                GUILayout.BeginHorizontal();
                {
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Tick", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col1),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Player", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col2),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Rpc ID", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.ExpandWidth(true),
                                     GUILayout.Height(cellHeight));
                }
                GUILayout.EndHorizontal();

                var events = this.target.GetEvents();
                foreach (var item in events)
                {
                    var tick = item.tick;
                    GUILayout.BeginHorizontal();
                    {
                        GUILayoutExt.DataLabel(tick.ToString(), GUILayout.Width(col1));
                    }
                    GUILayout.EndHorizontal();

                    var playerId = item.order;
                    GUILayout.BeginHorizontal();
                    {
                        GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(tick.ToString()); }, tableStyle, GUILayout.Width(col1), GUILayout.Height(cellHeight));
                        GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(playerId.ToString()); }, tableStyle, GUILayout.Width(col2), GUILayout.Height(cellHeight));
                        GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(item.rpcId.ToString()); }, tableStyle, GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                    }
                    GUILayout.EndHorizontal();
                }
            });
            this.eventsFoldState = val;

            return(false);
        }
Ejemplo n.º 3
0
        private WorldEditor DrawWorlds()
        {
            WorldEditor selectedWorld = null;
            var         style         = EditorStyles.helpBox;

            this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, style, GUILayout.ExpandHeight(true));
            {
                if (this.worlds.Count == 0)
                {
                    var centeredStyle = new GUIStyle(EditorStyles.centeredGreyMiniLabel);
                    centeredStyle.stretchHeight = true;
                    centeredStyle.richText      = true;
                    GUILayout.Label("This is runtime utility to view current running worlds.\nPress <b>Play</b> to start profiling.", centeredStyle);
                }
                else
                {
                    foreach (var worldEditor in this.worlds)
                    {
                        var systems         = worldEditor.GetSystems();
                        var modules         = worldEditor.GetModules();
                        var entitiesStorage = worldEditor.GetEntitiesStorage();
                        var filters         = worldEditor.GetFilters();
                        var world           = worldEditor.world;

                        GUILayoutExt.Padding(4f, () => {
                            GUILayoutExt.FoldOut(ref worldEditor.foldout, worldEditor.ToString() + " (Hash: " + worldEditor.world.GetStateHash() + ")", () => {
                                GUILayoutExt.Box(2f, 4f, () => {
                                    GUILayout.Label("Last Entity Id: " + worldEditor.world.GetLastEntityId().ToString());
                                    GUILayout.Label("State Tick: " + worldEditor.world.GetStateTick().ToString());
                                    GUILayout.Label("Tick: " + worldEditor.world.GetCurrentTick().ToString());
                                    GUILayout.Label("Tick Time: " + worldEditor.world.GetTickTime().ToString() + "ms.");
                                    GUILayout.Label("Time: " + ME.ECS.MathUtils.SecondsToString(worldEditor.world.GetTimeSinceStart()));
                                });

                                GUILayoutExt.FoldOut(ref worldEditor.foldoutSystems, "Systems (" + systems.Count.ToString() + ")", () => {
                                    var cellHeight = 25f;
                                    var padding    = 2f;
                                    var margin     = 1f;
                                    var col1       = 250f;
                                    var col2       = 50f;
                                    var col3       = 50f;
                                    var tableStyle = (GUIStyle)"Box";
                                    var dataStyle  = new GUIStyle(EditorStyles.label);
                                    GUILayoutExt.Padding(4f, () => {
                                        GUILayout.BeginHorizontal();
                                        {
                                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Caption", EditorStyles.miniBoldLabel); }, tableStyle,
                                                             GUILayout.Width(col1),
                                                             GUILayout.Height(cellHeight));
                                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Logic", EditorStyles.miniBoldLabel); }, tableStyle,
                                                             GUILayout.Width(col2),
                                                             GUILayout.Height(cellHeight));
                                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Visual", EditorStyles.miniBoldLabel); }, tableStyle,
                                                             GUILayout.Width(col3),
                                                             GUILayout.Height(cellHeight));
                                        }
                                        GUILayout.EndHorizontal();

                                        foreach (var system in systems)
                                        {
                                            GUILayout.BeginHorizontal();
                                            {
                                                GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TypeLabel(system.GetType()); }, tableStyle, GUILayout.Width(col1),
                                                                 GUILayout.Height(cellHeight));
                                            }
                                            { // Logic
                                                GUILayoutExt.Box(padding, margin, () => {
                                                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                                                    GUILayout.FlexibleSpace();

                                                    var flag  = world.GetSystemState(system);
                                                    var state = (flag & ME.ECS.ModuleState.LogicInactive) == 0;
                                                    if (this.ToggleMethod(worldEditor, system, "AdvanceTick", ref state) == true)
                                                    {
                                                        world.SetSystemState(
                                                            system, state == false ? flag | ME.ECS.ModuleState.LogicInactive : flag & ~ME.ECS.ModuleState.LogicInactive);
                                                    }

                                                    GUILayout.FlexibleSpace();
                                                    GUILayout.EndHorizontal();
                                                }, tableStyle, GUILayout.Width(col2), GUILayout.Height(cellHeight));
                                            }
                                            { // Visual
                                                GUILayoutExt.Box(padding, margin, () => {
                                                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                                                    GUILayout.FlexibleSpace();

                                                    var flag  = world.GetSystemState(system);
                                                    var state = (flag & ME.ECS.ModuleState.VisualInactive) == 0;
                                                    if (this.ToggleMethod(worldEditor, system, "Update", ref state) == true)
                                                    {
                                                        world.SetSystemState(
                                                            system, state == false ? flag | ME.ECS.ModuleState.VisualInactive : flag & ~ME.ECS.ModuleState.VisualInactive);
                                                    }

                                                    GUILayout.FlexibleSpace();
                                                    GUILayout.EndHorizontal();
                                                }, tableStyle, GUILayout.Width(col3), GUILayout.Height(cellHeight));
                                            }
                                            GUILayout.EndHorizontal();

                                            {
                                                GUILayoutExt.Box(padding, margin, () => {
                                                    /*if (system is IGUIEditor systemEditor) {
                                                     *
                                                     *  systemEditor.OnDrawGUI();
                                                     *
                                                     * }*/
                                                }, tableStyle, GUILayout.ExpandWidth(true));
                                                GUILayout.Space(2f);
                                            }
                                        }
                                    });
                                });

                                GUILayoutExt.FoldOut(ref worldEditor.foldoutModules, "Modules (" + modules.Count.ToString() + ")", () => {
                                    var cellHeight     = 25f;
                                    var padding        = 2f;
                                    var margin         = 1f;
                                    var col2           = 50f;
                                    var col3           = 50f;
                                    var tableStyle     = (GUIStyle)"Box";
                                    var dataStyle      = new GUIStyle(EditorStyles.label);
                                    dataStyle.richText = true;
                                    dataStyle.wordWrap = true;
                                    GUILayoutExt.Padding(4f, () => {
                                        GUILayout.BeginHorizontal();
                                        {
                                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Caption", EditorStyles.miniBoldLabel); }, tableStyle,
                                                             GUILayout.ExpandWidth(true),
                                                             GUILayout.Height(cellHeight));
                                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Logic", EditorStyles.miniBoldLabel); }, tableStyle,
                                                             GUILayout.Width(col2),
                                                             GUILayout.Height(cellHeight));
                                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Visual", EditorStyles.miniBoldLabel); }, tableStyle,
                                                             GUILayout.Width(col3),
                                                             GUILayout.Height(cellHeight));
                                            //GUILayoutExt.Box(2f, 1f, () => { GUILayoutExt.TableCaption("Info", EditorStyles.miniBoldLabel); }, tableStyle,
                                            //                 GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                                        }
                                        GUILayout.EndHorizontal();

                                        foreach (var module in modules)
                                        {
                                            GUILayout.BeginHorizontal();
                                            {
                                                GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TypeLabel(module.GetType()); }, tableStyle, GUILayout.ExpandWidth(true),
                                                                 GUILayout.Height(cellHeight));
                                            }
                                            { // Logic
                                                GUILayoutExt.Box(padding, margin, () => {
                                                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                                                    GUILayout.FlexibleSpace();

                                                    var flag  = world.GetModuleState(module);
                                                    var state = (flag & ME.ECS.ModuleState.LogicInactive) == 0;
                                                    if (this.ToggleMethod(worldEditor, module, "AdvanceTick", ref state) == true)
                                                    {
                                                        world.SetModuleState(
                                                            module, state == false ? flag | ME.ECS.ModuleState.LogicInactive : flag & ~ME.ECS.ModuleState.LogicInactive);
                                                    }

                                                    GUILayout.FlexibleSpace();
                                                    GUILayout.EndHorizontal();
                                                }, tableStyle, GUILayout.Width(col2), GUILayout.Height(cellHeight));
                                            }
                                            { // Visual
                                                GUILayoutExt.Box(padding, margin, () => {
                                                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                                                    GUILayout.FlexibleSpace();

                                                    var flag  = world.GetModuleState(module);
                                                    var state = (flag & ME.ECS.ModuleState.VisualInactive) == 0;
                                                    if (this.ToggleMethod(worldEditor, module, "Update", ref state) == true)
                                                    {
                                                        world.SetModuleState(
                                                            module, state == false ? flag | ME.ECS.ModuleState.VisualInactive : flag & ~ME.ECS.ModuleState.VisualInactive);
                                                    }

                                                    GUILayout.FlexibleSpace();
                                                    GUILayout.EndHorizontal();
                                                }, tableStyle, GUILayout.Width(col3), GUILayout.Height(cellHeight));
                                            }
                                            GUILayout.EndHorizontal();

                                            {
                                                GUILayoutExt.Box(padding, margin, () => {
                                                    var editor = this.GetEditor(module);
                                                    if (editor != null)
                                                    {
                                                        editor.OnDrawGUI();
                                                    }
                                                }, tableStyle, GUILayout.ExpandWidth(true));
                                                GUILayout.Space(2f);
                                            }
                                        }
                                    });
                                });

                                var entitiesCount = 0;
                                foreach (var entityStorage in entitiesStorage)
                                {
                                    if (entityStorage == null)
                                    {
                                        continue;
                                    }

                                    var storages = entityStorage.Cast <ME.ECS.IStorage>().ToList();
                                    foreach (var storage in storages)
                                    {
                                        if (storage == null)
                                        {
                                            continue;
                                        }

                                        entitiesCount += storage.Count;
                                    }
                                }

                                GUILayoutExt.FoldOut(ref worldEditor.foldoutEntitiesStorage, "Entities (" + entitiesCount.ToString() + ")", () => {
                                    var cellHeight = 25f;
                                    var padding    = 2f;
                                    var margin     = 1f;
                                    //var col1 = 80f;
                                    var tableStyle     = (GUIStyle)"Box";
                                    var dataStyle      = new GUIStyle(EditorStyles.label);
                                    dataStyle.richText = true;
                                    GUILayoutExt.Padding(4f, () => {
                                        GUILayout.BeginHorizontal();
                                        {
                                            /*GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Caption", EditorStyles.miniBoldLabel); }, tableStyle,
                                             *               GUILayout.Width(col1),
                                             *               GUILayout.Height(cellHeight));*/
                                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Data", EditorStyles.miniBoldLabel); }, tableStyle,
                                                             GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                                        }
                                        GUILayout.EndHorizontal();

                                        GUILayout.BeginVertical();
                                        foreach (var entityStorage in entitiesStorage)
                                        {
                                            if (entityStorage == null)
                                            {
                                                continue;
                                            }

                                            var storages = entityStorage.Cast <ME.ECS.IStorage>().ToList();
                                            foreach (var storage in storages)
                                            {
                                                if (storage == null)
                                                {
                                                    continue;
                                                }

                                                GUILayout.BeginHorizontal();
                                                {
                                                    GUILayoutExt.Box(
                                                        padding,
                                                        margin,
                                                        () => {
                                                        GUILayoutExt.TypeLabel(storage.GetType());
                                                        GUILayout.Label(storage.ToString(), dataStyle);
                                                    },
                                                        tableStyle,
                                                        GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                                                }
                                                GUILayout.EndHorizontal();
                                            }
                                        }
                                        GUILayout.EndVertical();
                                    });
                                });

                                var filtersCount = filters.Count;
                                GUILayoutExt.FoldOut(ref worldEditor.foldoutFilters, "Filters (" + filtersCount.ToString() + ")", () => {
                                    var cellHeight = 25f;
                                    var padding    = 2f;
                                    var margin     = 1f;
                                    //var col1 = 80f;
                                    var tableStyle     = (GUIStyle)"Box";
                                    var dataStyle      = new GUIStyle(EditorStyles.label);
                                    dataStyle.richText = true;
                                    GUILayoutExt.Padding(4f, () => {
                                        GUILayout.BeginHorizontal();
                                        {
                                            /*GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Caption", EditorStyles.miniBoldLabel); }, tableStyle,
                                             *               GUILayout.Width(col1),
                                             *               GUILayout.Height(cellHeight));*/
                                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Data", EditorStyles.miniBoldLabel); }, tableStyle,
                                                             GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                                        }
                                        GUILayout.EndHorizontal();

                                        GUILayout.BeginVertical();
                                        foreach (var filter in filters.GetData())
                                        {
                                            GUILayout.BeginHorizontal();
                                            {
                                                GUILayoutExt.Box(
                                                    padding,
                                                    margin,
                                                    () => {
                                                    GUILayoutExt.TypeLabel(filter.GetType());
                                                    GUILayout.Label(filter.ToString(), dataStyle);
                                                },
                                                    tableStyle,
                                                    GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                                            }
                                            GUILayout.EndHorizontal();
                                        }
                                        GUILayout.EndVertical();
                                    });
                                });
                            });

                            if (worldEditor.foldout == true)
                            {
                                selectedWorld = worldEditor;

                                // Fold in all others
                                foreach (var wEditor in this.worlds)
                                {
                                    if (wEditor != worldEditor)
                                    {
                                        wEditor.foldout = false;
                                    }
                                }
                            }
                        });

                        GUILayoutExt.Separator();
                    }
                }
            }
            GUILayout.EndScrollView();

            return(selectedWorld);
        }