예제 #1
0
        void CellGUI(Rect cellRect, TreeViewItem <MemoryElement> item, MyColumns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);

            switch (column)
            {
            case MyColumns.Type:
                DefaultGUI.Label(cellRect, item.data.type, args.selected, args.focused);
                break;

            case MyColumns.ClassName:
                DefaultGUI.Label(cellRect, item.data.className, args.selected, args.focused);
                break;

            case MyColumns.InstanceID:
                DefaultGUI.LabelRightAligned(cellRect, item.data.id.ToString(), args.selected, args.focused);
                break;

            case MyColumns.Size:
                DefaultGUI.LabelRightAligned(cellRect, item.data.size.ToString("f2"), args.selected, args.focused);
                break;

            case MyColumns.Name:
                DefaultGUI.Label(cellRect, item.data.name, args.selected, args.focused);
                break;
            }
        }
예제 #2
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);
        }
예제 #3
0
        static void IncomingChangeTreeViewItemCellGUI(
            string wkPath,
            Rect rect,
            float rowHeight,
            UnityIncomingChangesTree incomingChangesTree,
            IncomingChangesTreeView treeView,
            ChangeTreeViewItem item,
            Action onCheckedNodeChanged,
            IncomingChangesTreeColumn column,
            bool isSelected,
            bool isFocused,
            bool isCurrentConflict,
            bool isSolvedConflict)
        {
            IncomingChangeInfo incomingChange = item.ChangeInfo;

            string label = incomingChange.GetColumnText(
                IncomingChangesTreeHeaderState.GetHeaderContent(column));

            if (column == IncomingChangesTreeColumn.Path)
            {
                if (incomingChangesTree.HasMeta(item.ChangeInfo))
                {
                    label = string.Concat(label, UnityConstants.TREEVIEW_META_LABEL);
                }

                Texture             icon            = GetIcon(wkPath, incomingChange);
                GetOverlayIcon.Data overlayIconData = GetOverlayData(
                    incomingChange, isSolvedConflict);

                bool wasChecked = incomingChange.IsChecked();

                bool isChecked = DrawTreeViewItem.ForCheckableItemCell(
                    rect, rowHeight, item.depth,
                    icon, overlayIconData, label,
                    isSelected, isFocused, isCurrentConflict,
                    wasChecked);

                incomingChange.UpdateCheckedState(isChecked);

                if (wasChecked != isChecked)
                {
                    UpdateCheckStateForSelection(treeView, item);
                    onCheckedNodeChanged();
                }

                return;
            }

            if (column == IncomingChangesTreeColumn.Size)
            {
                DefaultGUI.LabelRightAligned(rect, label, isSelected, isFocused);
                return;
            }

            DefaultGUI.Label(rect, label, isSelected, isFocused);
        }
예제 #4
0
        protected override void RowGUI(RowGUIArgs args)
        {
            if (args.item is Element element)
            {
                int columnCount = args.GetNumVisibleColumns();

                for (int i0 = 0; i0 < columnCount; ++i0)
                {
                    var cellRect    = args.GetCellRect(i0);
                    var columnIndex = args.GetColumn(i0);

                    CenterRectUsingSingleLineHeight(ref cellRect);

                    switch ((Column)(1 << columnIndex))
                    {
                    case Column.kName:
                    {
                        base.RowGUI(args);
                        break;
                    }

                    case Column.kExtension:
                    {
                        DefaultGUI.Label(cellRect, element.extension, args.selected, args.focused);
                        break;
                    }

                    case Column.kPath:
                    {
                        DefaultGUI.Label(cellRect, element.path, args.selected, args.focused);
                        break;
                    }

                    case Column.kGuid:
                    {
                        DefaultGUI.Label(cellRect, element.guid, args.selected, args.focused);
                        break;
                    }

                    case Column.kReference:
                    {
                        if (element.reference >= 0)
                        {
                            DefaultGUI.LabelRightAligned(cellRect, element.reference.ToString(), args.selected, args.focused);
                        }
                        break;
                    }

                    default:
                    {
                        base.RowGUI(args);
                        break;
                    }
                    }
                }
            }
        }
예제 #5
0
        protected void DrawCount(RowGUIArgs args)
        {
            EntityQuery entityQuery;

            if (componentGroupsById.TryGetValue(args.item.id, out entityQuery))
            {
                var countString = entityQuery.CalculateLength().ToString();
                DefaultGUI.LabelRightAligned(args.rowRect, countString, args.selected, args.focused);
            }
        }
        protected override void RowGUI(RowGUIArgs args)
        {
            base.RowGUI(args);
            if (!componentGroupsById.ContainsKey(args.item.id))
            {
                return;
            }
            var countString = componentGroupsById[args.item.id].CalculateLength().ToString();

            DefaultGUI.LabelRightAligned(args.rowRect, countString, args.selected, args.focused);
        }
예제 #7
0
            protected override void RowGUI(RowGUIArgs args)
            {
                var item = (LuaMemoryTreeViewItem)args.item;

                for (int i = 0; i < args.GetNumVisibleColumns(); ++i)
                {
                    var cellRect = args.GetCellRect(i);

                    string value = "";
                    switch (args.GetColumn(i))
                    {
                    case 0:
                        value = item.displayName;
                        break;

                    case 1:
                        value = item.count.ToString();
                        break;

                    case 2:
                        value = EditorUtility.FormatBytes(Mathf.RoundToInt(item.memory));
                        break;

                    case 3:
                        value = EditorUtility.FormatBytes(Mathf.RoundToInt(item.avgMemory));
                        break;
                    }

                    if (i == 0)
                    {
                        DefaultGUI.Label(cellRect, value, args.selected, args.focused);
                    }
                    else
                    {
                        DefaultGUI.LabelRightAligned(cellRect, value, args.selected, args.focused);
                    }
                }
            }
예제 #8
0
    void CellGUI(Rect cellRect, TreeViewItem <RollEntry> item, MyColumns column, ref RowGUIArgs args)
    {
        // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
        CenterRectUsingSingleLineHeight(ref cellRect);

        switch (column)
        {
        case MyColumns.Icon:
        {
            GUI.DrawTexture(cellRect, s_TestIcons[0], ScaleMode.ScaleToFit);
        }
        break;

        case MyColumns.Name:
        {
            // Do toggle
            Rect toggleRect = cellRect;
            toggleRect.x    += GetContentIndent(item);
            toggleRect.width = kToggleWidth;
//                if (toggleRect.xMax < cellRect.xMax)
//                    item.data.enabled = EditorGUI.Toggle(toggleRect, item.data.enabled); // hide when outside cell rect

            // Default icon and label
            args.rowRect = cellRect;
            base.RowGUI(args);
        }
        break;

        case MyColumns.Object:
        case MyColumns.Weight:
        case MyColumns.DropChance:

        {
            if (showControls)
            {
                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    cellRect.xMin += 5f;     // When showing controls make some extra spacing
                    if (column == MyColumns.Object)
                    {
                        item.data.myObject = EditorGUI.ObjectField(cellRect, item.data.myObject,
                                                                   typeof(UnityEngine.Object), true);
                    }
                    if (column == MyColumns.Weight)
                    {
                        item.data.weight =
                            EditorGUI.IntField(cellRect, item.data.weight);
                    }
                    //TODO DropChance Direct edit : half reduces entire tree proportionally, half increases m_Weight proportionately
                    if (column == MyColumns.DropChance)
                    {
                        EditorGUI.LabelField(cellRect,
                                             item.data.localDropChance.ToString());
                    }

                    if (check.changed)
                    {
                        TableModel.UpdateModel();
                    }
                }
//                    if (column == MyColumns.GuaranteeBonus)
//                        item.data.m_GuaranteeBonus = EditorGUI.IntField(cellRect, item.data.m_GuaranteeBonus);
            }
            else
            {
                string value = "Missing";
                if (column == MyColumns.Object)
                {
                    if (item.data != null && item.data.myObject != null)
                    {
                        value = item.data.myObject.ToString();
                    }
                }

                if (column == MyColumns.Weight)
                {
                    value = item.data.weight.ToString("f5");
                }
                if (column == MyColumns.DropChance)
                {
                    value = item.data.localDropChance.ToString("f5");
                }
//                    if (column == MyColumns.GuaranteeBonus)
//                        value = item.data.m_GuaranteeBonus.ToString("f5");

                DefaultGUI.LabelRightAligned(cellRect, value, args.selected, args.focused);
            }
        }
        break;
        }
    }
예제 #9
0
    void CellGUI(Rect cellRect, UnityEditor.TreeViewExamples.TreeViewItem <VideoDataTreeElement> item, MyColumns column, ref RowGUIArgs args)
    {
        // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
        CenterRectUsingSingleLineHeight(ref cellRect);

        switch (column)
        {
        case MyColumns.Narration:
        {
            args.rowRect = cellRect;
            base.RowGUI(args);
        }
        break;

        case MyColumns.Verb:
        {
            string value = item.data.display_verb;
            if (item.depth == 0 && showControls)
            {
                value = "";
            }
            DefaultGUI.LabelRightAligned(cellRect, value, args.selected, args.focused);

            break;
        }

        case MyColumns.Noun:
        {
            string value = item.data.display_noun;
            if (item.depth == 0 && showControls)
            {
                value = "";
            }
            DefaultGUI.LabelRightAligned(cellRect, value, args.selected, args.focused);
            break;
        }

        case MyColumns.Occurences:
        {
            int    occurences = item.data.display_occurences_count;
            string value;
            if (occurences == -1)
            {
                TrainActionLabel v = item.data.occurences[0];
                value = string.Format("{0:0.##} seconds", ((float)(v.stop_frame - v.start_frame) / 30f));
            }
            else
            {
                value = occurences.ToString();
            }

            DefaultGUI.LabelRightAligned(cellRect, value, args.selected, args.focused);
        }
        break;

        case MyColumns.PlayVideo:
        {
            if (item.depth == 2)
            {
                if (GUI.Button(cellRect, "Play"))
                {
                    VideoPlayerWindow.GetWindow <VideoPlayerWindow>().PlayClip(item.data.occurences[0]);
                }
            }
        }
        break;
        }
    }
        void CellGUI(Rect cellRect, TreeViewItem <AH_TreeviewElement> item, MyColumns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);
            AH_TreeviewElement element = (AH_TreeviewElement)item.data;

            switch (column)
            {
            case MyColumns.Icon:
            {
                if (item.data.AssetType != null)
                {
                    GUI.DrawTexture(cellRect, AH_TreeviewElement.GetIcon(item.data.AssetType), ScaleMode.ScaleToFit);
                }
            }
            break;

            case MyColumns.Name:
            {
                Rect nameRect = cellRect;
                nameRect.x += GetContentIndent(item);
                DefaultGUI.Label(nameRect, item.data.m_Name, args.selected, args.focused);
            }
            break;

            case MyColumns.AssetSize:
            case MyColumns.FileSize:
            {
                string value = "";
                if (column == MyColumns.AssetSize && element.AssetSize > 0)
                {
                    value = element.AssetSizeStringRepresentation;
                }
                if (column == MyColumns.FileSize && element.FileSize > 0)
                {
                    value = element.FileSizeStringRepresentation;
                }


                if (element.IsFolder && column == MyColumns.FileSize /*&& !IsExpanded(element.id)*/)
                {
                    value = "{" + AH_Utils.BytesToString(element.GetFileSizeRecursively(((AH_MultiColumnHeader)multiColumnHeader).ShowMode)) + "}";
                    DefaultGUI.Label(cellRect, value, args.selected, args.focused);
                }
                else
                {
                    DefaultGUI.LabelRightAligned(cellRect, value, args.selected, args.focused);
                }
            }
            break;

            case MyColumns.UsedInBuild:
            {
                if (item.data.UsedInBuild)
                {
                    DefaultGUI.LabelRightAligned(cellRect, "\u2713", args.selected, args.focused);
                }
            }
            break;

            case MyColumns.LevelUsage:
            {
                if (item.data.UsedInBuild && item.data.ScenesReferencingAsset != null)
                {
                    if (item.data.ScenesReferencingAsset.Count > 0)
                    {
                        string cellString = String.Format("Usage: {0}", item.data.ScenesReferencingAsset.Count.ToString());
                        if (args.selected && args.focused)
                        {
                            if (GUI.Button(cellRect, cellString))
                            {
                                UnityEngine.Object[] sceneAssets = new UnityEngine.Object[item.data.ScenesReferencingAsset.Count];
                                string message = "";

                                for (int i = 0; i < item.data.ScenesReferencingAsset.Count; i++)
                                {
                                    message       += (item.data.ScenesReferencingAsset[i] + Environment.NewLine);
                                    sceneAssets[i] = AssetDatabase.LoadMainAssetAtPath(item.data.ScenesReferencingAsset[i]);
                                }
                                Selection.objects = sceneAssets;
                                EditorUtility.DisplayDialog("Scenes referencing " + item.data.m_Name, message, "OK");
                            }
                        }
                        else
                        {
                            DefaultGUI.LabelRightAligned(cellRect, cellString, args.selected, args.focused);
                        }
                    }

                    /*else
                     *  DefaultGUI.LabelRightAligned(cellRect, "Global", args.selected, args.focused);*/
                }
            }
            break;
            }
        }