private void CalculateDrawingParts(float newWidth)
        {
            width = newWidth;
            stylesById.Clear();
            namesById.Clear();
            rectsById.Clear();
            heightsById.Clear();
            foreach (var idGroupPair in componentGroupsById)
            {
                ComponentGroupGUI.CalculateDrawingParts(new List <ComponentType>(idGroupPair.Value.Types.Skip(1)), false, width, out var height, out var styles, out var names, out var rects);
                stylesById.Add(idGroupPair.Key, styles);
                namesById.Add(idGroupPair.Key, names);
                rectsById.Add(idGroupPair.Key, rects);
                heightsById.Add(idGroupPair.Key, height);
            }
            foreach (var idQueryPair in queriesById)
            {
                var types = new List <ComponentType>();
                types.AddRange(idQueryPair.Value.All);
                types.AddRange(idQueryPair.Value.Any);
                types.AddRange(idQueryPair.Value.None.Select(x => ComponentType.Subtractive(x.GetManagedType())));

                ComponentGroupGUI.CalculateDrawingParts(types, true, width, out var height, out var styles, out var names, out var rects);
                stylesById.Add(idQueryPair.Key, styles);
                namesById.Add(idQueryPair.Key, names);
                rectsById.Add(idQueryPair.Key, rects);
                heightsById.Add(idQueryPair.Key, height);
            }
            RefreshCustomRowHeights();
        }
        public void OnGUI()
        {
            GUILayout.Label("Filter: ");
            var filterCount = 0;

            for (var i = 0; i < selectedFilterTypes.Count; ++i)
            {
                if (selectedFilterTypes[i])
                {
                    ++filterCount;
                    var style = filterTypes[i].AccessModeType == ComponentType.AccessMode.Subtractive ? EntityDebuggerStyles.ComponentSubtractive : EntityDebuggerStyles.ComponentRequired;
                    GUILayout.Label(ComponentGroupGUI.SpecifiedTypeName(filterTypes[i].GetManagedType()), style);
                }
            }
            if (filterCount == 0)
            {
                GUILayout.Label("none");
            }
            if (GUILayout.Button("Edit"))
            {
                ComponentTypeChooser.Open(GUIUtility.GUIToScreenPoint(GUILayoutUtility.GetLastRect().position), filterTypes, selectedFilterTypes, ComponentFilterChanged);
            }
            if (filterCount > 0)
            {
                if (GUILayout.Button("Clear"))
                {
                    for (var i = 0; i < selectedFilterTypes.Count; ++i)
                    {
                        selectedFilterTypes[i] = false;
                    }
                    ComponentFilterChanged();
                }
            }
        }
Пример #3
0
        protected override void RowGUI(RowGUIArgs args)
        {
            base.RowGUI(args);
            if (!componentGroupsById.ContainsKey(args.item.id) || Event.current.type != EventType.Repaint)
            {
                return;
            }

            var componentGroup = componentGroupsById[args.item.id];

            var position = args.rowRect.position;

            position.x  = GetContentIndent(args.item);
            position.y += 1;

            ComponentGroupGUI.DrawComponentList(
                new Rect(position.x, position.y, componentGroupHeightsById[args.item.id], width),
                componentGroupStylesById[args.item.id],
                componentGroupNamesById[args.item.id],
                componentGroupRectsById[args.item.id]);

            var countString = componentGroup.CalculateLength().ToString();

            DefaultGUI.LabelRightAligned(args.rowRect, countString, args.selected, args.focused);
        }
 public ComponentTypeListView(TreeViewState state, List <ComponentType> types, List <bool> typeSelections, CallbackAction callback) : base(state)
 {
     this.callback       = callback;
     this.types          = types;
     this.typeSelections = typeSelections;
     typeNames           = new List <GUIContent>(types.Count);
     for (var i = 0; i < types.Count; ++i)
     {
         typeNames.Add(new GUIContent(ComponentGroupGUI.SpecifiedTypeName(types[i].GetManagedType())));
     }
     Reload();
 }
Пример #5
0
        void CalculateDrawingParts(IEnumerable <ComponentType> types)
        {
            var typeList = types.ToList();

            typeList.Sort((Comparison <ComponentType>)ComponentGroupGUI.CompareTypes);
            styles = new List <GUIStyle>(typeList.Count);
            names  = new List <GUIContent>(typeList.Count);
            rects  = new List <Rect>(typeList.Count);
            foreach (var type in typeList)
            {
                var style   = ComponentGroupGUI.StyleForAccessMode(type.AccessModeType, archetypeQueryMode);
                var content = new GUIContent((string)ComponentGroupGUI.SpecifiedTypeName(type.GetManagedType()));

                styles.Add(style);
                names.Add(content);
            }
        }
Пример #6
0
 private void CalculateDrawingParts(float newWidth)
 {
     width = newWidth;
     componentGroupStylesById.Clear();
     componentGroupNamesById.Clear();
     componentGroupRectsById.Clear();
     componentGroupHeightsById.Clear();
     foreach (var idGroupPair in componentGroupsById)
     {
         ComponentGroupGUI.CalculateDrawingParts(idGroupPair.Value.Types, width, out var height, out var styles, out var names, out var rects);
         componentGroupStylesById.Add(idGroupPair.Key, styles);
         componentGroupNamesById.Add(idGroupPair.Key, names);
         componentGroupRectsById.Add(idGroupPair.Key, rects);
         componentGroupHeightsById.Add(idGroupPair.Key, height);
     }
     RefreshCustomRowHeights();
 }
        void CalculateDrawingParts(IEnumerable <ComponentType> types, IEnumerable <ComponentType> readWriteTypes, bool archetypeQueryMode)
        {
            var typeList = types.ToList();

            typeList.Sort((Comparison <ComponentType>)ComponentGroupGUI.CompareTypes);
            styles = new List <GUIStyle>(typeList.Count);
            names  = new List <GUIContent>(typeList.Count);
            rects  = new List <Rect>(typeList.Count);
            foreach (var type in typeList)
            {
                GUIStyle style = null;
                if (readWriteTypes != null)
                {
                    foreach (var readWriteType in readWriteTypes)
                    {
                        if (readWriteType.TypeIndex == type.TypeIndex)
                        {
                            style = ComponentGroupGUI.StyleForAccessMode(readWriteType.AccessModeType, archetypeQueryMode);
                            break;
                        }
                    }

                    if (style == null)
                    {
                        if (type.AccessModeType == ComponentType.AccessMode.Subtractive)
                        {
                            style = EntityDebuggerStyles.ComponentSubtractive;
                        }
                        else
                        {
                            style = EntityDebuggerStyles.ComponentRequired;
                        }
                    }
                }
                else
                {
                    style = ComponentGroupGUI.StyleForAccessMode(type.AccessModeType, archetypeQueryMode);
                }
                var content = new GUIContent((string)ComponentGroupGUI.SpecifiedTypeName(type.GetManagedType()));

                styles.Add(style);
                names.Add(content);
            }
        }
        public void OnGUI(World world, Entity entity)
        {
            ++EditorGUI.indentLevel;
            GUILayout.BeginVertical(GUI.skin.box);
            showSystems = EditorGUILayout.Foldout(showSystems, "Used by Systems");

            if (showSystems)
            {
                if (repainted == true)
                {
                    cachedMatches.Clear();
                    WorldDebuggingTools.MatchEntityInComponentGroups(world, entity, cachedMatches);
                    repainted = false;
                }

                foreach (var pair in cachedMatches)
                {
                    var type = pair.Item1.GetType();
                    GUILayout.Label(new GUIContent(type.Name, type.AssemblyQualifiedName));
                    ++EditorGUI.indentLevel;
                    foreach (var componentGroup in pair.Item2)
                    {
                        ComponentGroupGUI.ComponentListGUILayout(componentGroup.Types, EditorGUIUtility.currentViewWidth - 30f);
                        if (GUILayout.Button("Show", GUILayout.ExpandWidth(false)))
                        {
                            EntityDebugger.SetAllSelections(world, pair.Item1 as ComponentSystemBase, new EntityListQuery(componentGroup), entity);
                        }
                    }

                    --EditorGUI.indentLevel;
                }

                if (Event.current.type == EventType.Repaint)
                {
                    repainted = true;
                }
            }
            GUILayout.EndVertical();

            --EditorGUI.indentLevel;
        }
        protected override void RowGUI(RowGUIArgs args)
        {
            base.RowGUI(args);
            if (Event.current.type != EventType.Repaint || !heightsById.ContainsKey(args.item.id))
            {
                return;
            }

            var position = args.rowRect.position;

            position.x  = GetContentIndent(args.item);
            position.y += 1;

            ComponentGroupGUI.DrawComponentList(
                new Rect(position.x, position.y, heightsById[args.item.id], width),
                stylesById[args.item.id],
                namesById[args.item.id],
                rectsById[args.item.id]);

            DrawCount(args);
        }