예제 #1
0
        void EntityHeader()
        {
            if (WorldSelection == null)
            {
                return;
            }
            GUILayout.BeginHorizontal();
            if (SystemSelection == null)
            {
                GUILayout.Label("All Entities", EditorStyles.boldLabel);
            }
            else
            {
                var type = SystemSelection.GetType();
                AlignHeader(() => GUILayout.Label(type.Namespace, EditorStyles.label));
                GUILayout.Label(type.Name, EditorStyles.boldLabel);

                GUILayout.FlexibleSpace();
                var system = SystemSelection as ComponentSystemBase;
                if (system != null)
                {
                    var running = system.Enabled && system.ShouldRunSystem();
                    AlignHeader(() => GUILayout.Label($"running: {(running ? "yes" : "no")}"));

                    if (running && system.ComponentGroups.Length > 0 && entityListView.SelectedComponentGroup.GetEntityArray().Length > 0)
                    {
                        if (GUILayout.Button("Dump entities to CSV file"))
                        {
                            DumpToCSVButton();
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();
        }
예제 #2
0
 private void EntityHeader()
 {
     GUILayout.BeginHorizontal(Styles.ToolbarStyle);
     if (HasWorld())
     {
         if (SystemSelection == null)
         {
             GUILayout.Label("All Entities", Styles.ToolbarLabelStyle);
         }
         else
         {
             var type = SystemSelection.GetType();
             if (!string.IsNullOrEmpty(type.Namespace))
             {
                 GUILayout.Label($"{type.Namespace}.{type.Name}", Styles.ToolbarLabelStyle);
             }
             else
             {
                 GUILayout.Label(type.Name, Styles.ToolbarLabelStyle);
             }
         }
     }
     else
     {
         GUILayout.Label("No World selected", Styles.ToolbarLabelStyle);
     }
     GUILayout.FlexibleSpace();
     ShowingChunkInfoView = GUILayout.Toggle(ShowingChunkInfoView, "Chunk Info", Styles.ToolbarButtonStyle);
     GUILayout.EndHorizontal();
 }
예제 #3
0
        void DumpToCSVButton()
        {
            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
            var visitor = new EntityCSVVisitor();

            visitor.m_stringBuilder = stringBuilder;

            var entityManager = WorldSelection.GetExistingManager <EntityManager>();
            var entityArray   = entityListView.SelectedComponentGroup.GetEntityArray();

            Debug.Log(SystemSelection.GetType().Name);
            var CSVPath = EditorUtility.SaveFilePanel("Save entities in selected component group to CSV file", "", "DumpedEntities" + ".csv", "csv");

            if (CSVPath.Length != 0)
            {
                for (int i = 0; i < entityArray.Length; i++)
                {
                    stringBuilder.Append("Entity " + entityArray[i].Index.ToString() + ",");
                    var container = new EntityContainer(entityManager, entityArray[i]);
                    container.PropertyBag.Visit(ref container, visitor);
                    stringBuilder.Remove(stringBuilder.Length - 1, 1);     // delete trailing comma on each line
                    stringBuilder.Append("\n");
                }
                System.IO.File.WriteAllText(CSVPath, stringBuilder.ToString());
            }
        }
예제 #4
0
        private static List <EntityQueryDesc> GetQueryDescsForSystem(SystemSelection system)
        {
            List <EntityQueryDesc> queryDescs;

            if (queryDescsBySystem.TryGetValue(system, out queryDescs))
            {
                return(queryDescs);
            }

            queryDescs = new List <EntityQueryDesc>();

            var currentType = system.GetType();

            while (currentType != null)
            {
                foreach (var field in currentType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
                {
                    if (field.FieldType == typeof(EntityQueryDesc))
                    {
                        queryDescs.Add(field.GetValue(system) as EntityQueryDesc);
                    }
                }

                currentType = currentType.BaseType;
            }

            return(queryDescs);
        }
예제 #5
0
 private void EntityHeader()
 {
     if (WorldSelection == null && SystemSelectionWorld == null)
     {
         return;
     }
     GUILayout.BeginHorizontal();
     if (SystemSelection == null)
     {
         GUILayout.Label("All Entities", EditorStyles.boldLabel);
     }
     else
     {
         var type = SystemSelection.GetType();
         AlignHeader(() => GUILayout.Label(type.Namespace, EditorStyles.label));
         GUILayout.Label(type.Name, EditorStyles.boldLabel);
         GUILayout.FlexibleSpace();
         var system = SystemSelection as ComponentSystemBase;
         if (system != null)
         {
             var running = system.Enabled && system.ShouldRunSystem();
             AlignHeader(() => GUILayout.Label($"running: {(running ? "yes" : "no")}"));
         }
     }
     GUILayout.EndHorizontal();
 }
예제 #6
0
        public static EntityQueryListView CreateList(SystemSelection system, List <TreeViewState> states, List <string> stateNames,
                                                     SetEntityListSelection entityQuerySelectionCallback, WorldSelectionGetter worldSelectionGetter)
        {
            var state = GetStateForSystem(system, states, stateNames);

            return(new EntityQueryListView(state, system, entityQuerySelectionCallback, worldSelectionGetter));
        }
예제 #7
0
        private unsafe static TreeViewState GetStateForSystem(SystemSelection system, List <TreeViewState> states, List <string> stateNames)
        {
            var ptr = system.StatePointer;

            if (ptr == null)
            {
                return(new TreeViewState());
            }

            var currentSystemName = system.GetType().FullName;

            var stateForCurrentSystem = states.Where((t, i) => stateNames[i] == currentSystemName).FirstOrDefault();

            if (stateForCurrentSystem != null)
            {
                return(stateForCurrentSystem);
            }

            stateForCurrentSystem = new TreeViewState();
            if (ptr->EntityQueries.Length > 0)
            {
                stateForCurrentSystem.expandedIDs = new List <int> {
                    1
                }
            }
            ;
            states.Add(stateForCurrentSystem);
            stateNames.Add(currentSystemName);
            return(stateForCurrentSystem);
        }
예제 #8
0
        HideNode BuildNodesForComponentSystem(SystemSelection systemBase, ref int currentId)
        {
            if (systemBase.Managed != null)
            {
                switch (systemBase.Managed)
                {
                case ComponentSystemGroup group:
                    List <HideNode> children = null;

                    ref var updateList = ref group.m_MasterUpdateList;

                    for (int i = 0, count = updateList.Length; i < count; ++i)
                    {
                        var updateIndex = updateList[i];

                        if (updateIndex.IsManaged)
                        {
                            var child = group.Systems[updateIndex.Index];
                            AddNodeIgnoreNulls(ref children, BuildNodesForComponentSystem(child, ref currentId));
                        }
                        else
                        {
                            var child = group.UnmanagedSystems[updateIndex.Index];
                            AddNodeIgnoreNulls(ref children, BuildNodesForComponentSystem(new SystemSelection(child, group.World), ref currentId));
                        }
                    }

                    if (children != null || getWorldSelection() == null || getWorldSelection() == group.World)
                    {
                        var groupNode = CreateNodeForSystem(currentId++, group);
                        groupNode.Children = children;
                        return(groupNode);
                    }
                    break;
예제 #9
0
 public EntityQueryListView(TreeViewState state, SystemSelection system, SetEntityListSelection entityListSelectionCallback, WorldSelectionGetter worldSelectionGetter) : base(state)
 {
     this.getWorldSelection           = worldSelectionGetter;
     this.entityListSelectionCallback = entityListSelectionCallback;
     selectedSystem = system;
     rowHeight     += 1;
     showAlternatingRowBackgrounds = true;
     Reload();
 }
예제 #10
0
 private void EntityHeader()
 {
     if (WorldSelection != null || SystemSelectionWorld != null)
     {
         var rect = new Rect(kSystemListWidth, 3f, CurrentEntityViewWidth, kLineHeight);
         if (SystemSelection == null)
         {
             GUI.Label(rect, "All Entities", EditorStyles.boldLabel);
         }
         else
         {
             var type = SystemSelection.GetType();
             GUI.Label(rect, $"<b>{type.Namespace}</b>.{type.Name}", LabelStyle);
         }
     }
     if (!showingChunkInfoView)
     {
         ChunkInfoToggle(new Rect(kSystemListWidth + CurrentEntityViewWidth - kChunkInfoButtonWidth, 0f, kChunkInfoButtonWidth, kLineHeight));
     }
 }
예제 #11
0
        HideNode CreateNodeForSystem(int id, SystemSelection sel)
        {
            var active = true;
            var type   = sel.GetSystemType();

            if (!typeof(ComponentSystemGroup).IsAssignableFrom(type))
            {
                systemsById.Add(id, sel);
                worldsById.Add(id, sel.World);
                var recorder = Recorder.Get($"{sel.World?.Name ?? "none"} {type.FullName}");
                if (!recordersBySystem.ContainsKey(sel))
                {
                    recordersBySystem.Add(sel, new AverageRecorder(recorder));
                }
                else
                {
                    UnityEngine.Debug.LogError("System added twice: " + sel);
                }
                recorder.enabled = true;
                active           = false;
            }

            var typeName = Properties.Editor.TypeUtility.GetTypeDisplayName(type);
            var name     = getWorldSelection() == null ? $"{typeName} ({sel.World?.Name ?? "none"})" : typeName;
            var item     = new TreeViewItem {
                id = id, displayName = name
            };

            var hideNode = new HideNode(item)
            {
                Active = active
            };

            hideNodesById.Add(id, hideNode);
            return(hideNode);
        }