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(); }
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")}")); } } GUILayout.EndHorizontal(); }
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()); } }
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(); }
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); }
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); }
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)); } }