Beispiel #1
0
        public BinaryContainer DrawContainerContent(Rect position)
        {
            BinaryContainer updatedContainer = null;

            _nextLineIsEven = false;
            var pos = position.SliceTop();

            GUI.contentColor = Color.white;
            EditorGUI.LabelField(pos.SliceRight(SizeWidth), _sizeText, Bold);
            GUI.contentColor = Color.grey;
            EditorGUI.LabelField(pos.SliceRight(36f), "Size:", NormalRight);
            GUI.contentColor = Color.white;
            EditorGUI.LabelField(pos.SliceRight(46f), Info.EntriesCount.ToString(), Bold);
            GUI.contentColor = Color.grey;
            EditorGUI.LabelField(pos.SliceRight(52f), "Objects:", NormalRight);
            EditorGUI.LabelField(pos.SliceLeft(60f), "Container", EditorStyles.boldLabel);
            GUI.contentColor = Color.white;

            if (Info.HasOldVersions)
            {
                var warnRect = position.SliceTop(EditorHelpers.GetLinesHeight(Editable ? 2 : 1));
                if (Editable &&
                    GUI.Button(warnRect.SliceRight(75f), UpdateSerializersButton))
                {
                    updatedContainer = Info.GetContainer();
                    updatedContainer.UpdateSerializers();
                }
                EditorGUI.HelpBox(warnRect, "Has old serializers (newer version exists). Marked with yellow", MessageType.Warning);
            }

            var colHeaderRect = position.SliceTop(); // reserve a line for columns rendering (later)

            position = position.Expand(2f);          // negate window margins
            GUILayout.BeginArea(position);
            _scrollViewHeight = position.height;
            _scrollPos        = EditorGUILayout.BeginScrollView(_scrollPos);
            _parentEntries.Clear();
            foreach (var e in Info.RootObjects)
            {
                DrawEntry(e);
            }
            GetNextLineVisible(out var innerLineRect);
            float inScrollWidth = innerLineRect.width;

            EditorGUILayout.EndScrollView();
            GUILayout.EndArea();

            // we render column header section after the table because we want to know its layout
            // particularly the width of the view area as the vertical scroll bar may or may not be visible
            GUI.contentColor = Color.gray;
            colHeaderRect    = colHeaderRect.SliceLeft(inScrollWidth, false);
            EditorGUI.LabelField(colHeaderRect.SliceLeft(_idWidth), "Id", NormalRight);
            EditorGUI.LabelField(colHeaderRect.SliceRight(18f), JsonLabel, NormalRight);
            if (GUI.Button(colHeaderRect.SliceRight(SizeWidth),
                           RenderTotalSize ? TotalSizeHeader : DataSizeHeader, NormalRight))
            {
                RenderTotalSize = !RenderTotalSize;
            }
            GUI.contentColor = RenderSelfSize ? Color.gray : new Color(0.5f, 0.5f, 0.5f, 0.4f);
            if (GUI.Button(colHeaderRect.SliceRight(SizeWidth), SelfSizeHeader, NormalRight))
            {
                RenderSelfSize = !RenderSelfSize;
            }
            colHeaderRect.SliceLeft(16f);
            GUI.contentColor = Color.gray;
            if (GUI.Button(colHeaderRect, RenderRefType ? "Ref : Object" : "Object", Normal))
            {
                RenderRefType = !RenderRefType;
            }

            if (!Editable & updatedContainer != null)
            {
                Debug.LogError("Trying to modify uneditable container!\n");
                updatedContainer = null;
            }
            return(updatedContainer);
        }