Ejemplo n.º 1
0
    private void CellGUI(Rect cellRect, AssetTreeViewItem item, int column, ref RowGUIArgs args)
    {
        Color oldColor = GUI.color;

        CenterRectUsingSingleLineHeight(ref cellRect);
        //if (column != 3)
        //    GUI.color = item.itemColor;
        if (!File.Exists(item.asset.data.path))
        {
            GUI.color = Color.red;
        }
        switch ((MyColumns)column)
        {
        case MyColumns.Asset:
        {
            var iconRect = new Rect(cellRect.x + 1, cellRect.y + 1, cellRect.height - 2, cellRect.height - 2);
            if (item.icon != null)
            {
                GUI.DrawTexture(iconRect, item.icon, ScaleMode.ScaleToFit);
            }

            DefaultGUI.Label(
                new Rect(cellRect.x + iconRect.xMax + 1, cellRect.y, cellRect.width - iconRect.width, cellRect.height),
                item.displayName,
                args.selected,
                args.focused);
        }
        break;

        case MyColumns.Size:
            DefaultGUI.Label(cellRect, item.asset.GetSizeString(), args.selected, args.focused);
            break;

        case MyColumns.Path:
            DefaultGUI.Label(cellRect, item.asset.data.path, args.selected, args.focused);
            break;
        }
        GUI.color = oldColor;
    }
Ejemplo n.º 2
0
        private void CellGUI(Rect cellRect, AssetReferenceTreeItem item, int column, ref RowGUIArgs args)
        {
            Color oldColor = GUI.color;

            CenterRectUsingSingleLineHeight(ref cellRect);
            GUI.color = Color.white;

            switch (column)
            {
            case 0:
            {
                var iconRect = new Rect(cellRect.x + 1, cellRect.y + 1, cellRect.height - 2, cellRect.height - 2);
                var icon     = item.icon;
                if (icon != null)
                {
                    GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleToFit);
                }
                DefaultGUI.Label(
                    new Rect(cellRect.x + iconRect.xMax + 1, cellRect.y, cellRect.width - iconRect.width, cellRect.height),
                    item.displayName,
                    args.selected,
                    args.focused);
            }
            break;

            case 1:
                DefaultGUI.Label(cellRect, item.asset.variantName, args.selected, args.focused);
                break;

            case 2:
                DefaultGUI.Label(cellRect, item.fileSize, args.selected, args.focused);
                break;

            case 3:
                DefaultGUI.Label(cellRect, item.runtimeMemorySize, args.selected, args.focused);
                break;
            }
            GUI.color = oldColor;
        }
Ejemplo n.º 3
0
        protected void CellGUI(Rect cellRect, TreeViewItem item, int column, ref RowGUIArgs args)
        {
            int pagesIndex = item.id % kPageCapacity;
            int atlasIndex = item.id / kPageCapacity;
            var info       = m_TreeModel.GetAtlasPagesInfo(atlasIndex, pagesIndex);

            switch (column)
            {
            case 0:
            {
                Rect position = cellRect;
                position.width  = 16f;
                position.height = 16f;
                position.y     += 2f;
                position.x     += 2f;
                Texture iconForItem = info.texture;
                if (iconForItem)
                {
                    GUI.DrawTexture(position, iconForItem, ScaleMode.ScaleToFit);
                }

                cellRect.xMin += 20f;
                DefaultGUI.Label(cellRect, item.displayName, args.selected, args.focused);
            }
            break;

            case 1:
                DefaultGUI.Label(cellRect, string.Format("Page {0}", pagesIndex + 1), args.selected, args.focused);
                break;

            case 2:
                DefaultGUI.Label(cellRect, info.size, args.selected, args.focused);
                break;

            case 3:
                DefaultGUI.Label(cellRect, info.format, args.selected, args.focused);
                break;
            }
        }
Ejemplo n.º 4
0
        void CellGUI(Rect cellRect, TreeViewItem <BehaviorTreeNode> item, ViewColumns column, ref RowGUIArgs args)
        {
            CenterRectUsingSingleLineHeight(ref cellRect);

            BehaviorTreeNode node = item.data;

            switch (column)
            {
            case ViewColumns.kIcon:
            {
                GUI.DrawTexture(cellRect, (Texture2D)EditorGUIUtility.Load(node.GetIconPath()), ScaleMode.ScaleToFit);
            }
            break;

            case ViewColumns.kName:
            {
                Rect toggleRect = cellRect;
                toggleRect.x    += GetContentIndent(item);
                toggleRect.width = TOGGLE_WIDTH;
                if (toggleRect.xMax < cellRect.xMax)
                {
                    item.data.DEBUG_on = EditorGUI.Toggle(toggleRect, item.data.DEBUG_on);
                }

                args.rowRect = cellRect;
                args.label   = item.data.Name;
                base.RowGUI(args);
            }
            break;

            case ViewColumns.kType:
            {
                cellRect.x += GetContentIndent(item);
                DefaultGUI.Label(cellRect, node.GetType().ToString().Split('.')[1], args.selected, args.focused);
            }
            break;
            }
        }
Ejemplo n.º 5
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);
                    }
                }
            }
Ejemplo n.º 6
0
        private void CellGUI(Rect cellRect, AssetBundleState.AssetInfo.TreeItem item, int column, ref RowGUIArgs args)
        {
            CenterRectUsingSingleLineHeight(ref cellRect);
            GUI.color = item.color;
            switch (column)
            {
            case 0:
            {
                var iconRect = new Rect(cellRect.x + 1, cellRect.y + 1, cellRect.height - 2, cellRect.height - 2);
                GUI.DrawTexture(iconRect, item.icon, ScaleMode.ScaleToFit);
                DefaultGUI.Label(new Rect(cellRect.x + iconRect.xMax + 1, cellRect.y, cellRect.width - iconRect.width, cellRect.height), item.displayName, args.selected, args.focused);
            }
            break;

            case 1:
                DefaultGUI.Label(cellRect, item.asset.m_bundle == null ? string.Empty : item.asset.m_bundle.m_name, args.selected, args.focused);
                break;

            case 2:
                DefaultGUI.Label(cellRect, item.asset.GetSizeString(), args.selected, args.focused);
                break;
            }
        }
        void CellGUI(Rect cellRect, TreeViewItem item, int column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);

            var snippetItem = item as SnippetItem;
            var snippet     = m_Model[snippetItem.index];

            switch (column)
            {
            case 0:
            {
                DefaultGUI.Label(cellRect, snippet.category, args.selected, args.focused);
            }
            break;

            case 1:
            {
                DefaultGUI.Label(cellRect, snippet.label, args.selected, args.focused);
            }
            break;
            }
        }
Ejemplo n.º 8
0
        private void CellGUI(Rect cellRect, AssetBundleModel.AssetTreeItem item, int column, ref RowGUIArgs args)
        {
            CenterRectUsingSingleLineHeight(ref cellRect);
            GUI.color = item.ItemColor;
            switch (column)
            {
            case 0:
            {
                var iconRect = new Rect(cellRect.x + 1, cellRect.y + 1, cellRect.height - 2, cellRect.height - 2);
                GUI.DrawTexture(iconRect, item.icon, ScaleMode.ScaleToFit);
                DefaultGUI.Label(
                    new Rect(cellRect.x + iconRect.xMax + 1, cellRect.y, cellRect.width - iconRect.width, cellRect.height),
                    item.displayName,
                    args.selected,
                    args.focused);
            }
            break;

            case 1:
                DefaultGUI.Label(cellRect, item.asset.BundleName, args.selected, args.focused);
                break;

            case 2:
                DefaultGUI.Label(cellRect, item.asset.GetSizeString(), args.selected, args.focused);
                break;

            case 3:
                var icon = AssetBundleModel.ProblemMessage.GetIcon(item.HighestMessageLevel());
                if (icon != null)
                {
                    //var iconRect = new Rect(cellRect.x + 1, cellRect.y + 1, cellRect.height - 2, cellRect.height - 2);
                    var iconRect = new Rect(cellRect.x, cellRect.y, cellRect.height, cellRect.height);
                    GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleToFit);
                }
                break;
            }
        }
Ejemplo n.º 9
0
        private void CellGUI(Rect cellRect, TreeViewItem item, int column, ref RowGUIArgs args)
        {
            GroupTreeViewItem groupItem = item as GroupTreeViewItem;

            if (groupItem == null)
            {
                return;
            }

            switch (column)
            {
            case 0:
                DefaultGUI.Label(cellRect, groupItem.name, args.selected, args.focused);
                break;

            case 1:
                DefaultGUI.Label(cellRect, groupItem.items.ToString(), args.selected, args.focused);
                break;

            case 2:
                DefaultGUI.Label(cellRect, EditorUtility.FormatBytes(groupItem.fileSize), args.selected, args.focused);
                break;
            }
        }
Ejemplo n.º 10
0
        protected override void DrawCell(ref Rect cellRect, MaintainerTreeViewItem <T> genericItem, int columnValue, RowGUIArgs args)
        {
            base.DrawCell(ref cellRect, genericItem, columnValue, args);

            var column = (Columns)columnValue;
            var item   = (HierarchyReferencesTreeViewItem <T>)genericItem;

            switch (column)
            {
            case Columns.Icon:

                if (item.depth == 0)
                {
                    if (item.icon != null)
                    {
                        var iconRect = cellRect;
                        iconRect.width  = IconWidth;
                        iconRect.height = EditorGUIUtility.singleLineHeight;

                        GUI.DrawTexture(iconRect, item.icon, ScaleMode.ScaleToFit);
                    }
                }

                break;

            case Columns.GameObject:

                var entryRect = cellRect;
                entryRect.xMin += baseIndent + UIHelpers.EyeButtonPadding;

                if (item.depth == 1)
                {
                    if (item.icon != null)
                    {
                        var iconRect = entryRect;
                        iconRect.xMin  -= UIHelpers.EyeButtonSize - UIHelpers.EyeButtonPadding;
                        iconRect.width  = IconWidth;
                        iconRect.x     += IconPadding;
                        iconRect.height = EditorGUIUtility.singleLineHeight;

                        GUI.DrawTexture(iconRect, item.icon, ScaleMode.ScaleToFit);
                    }
                }
                else
                {
                    /*entryRect.xMin += baseIndent + UIHelpers.EyeButtonPadding;*/
                }

                Rect lastRect;
                var  eyeButtonRect = entryRect;
                eyeButtonRect.xMin  += IconPadding;
                eyeButtonRect.width  = UIHelpers.EyeButtonSize;
                eyeButtonRect.height = UIHelpers.EyeButtonSize;
                eyeButtonRect.x     += UIHelpers.EyeButtonPadding;

                lastRect = eyeButtonRect;

                if (UIHelpers.IconButton(eyeButtonRect, CSIcons.Show))
                {
                    ShowItem(item);
                }

                var labelRect = entryRect;
                labelRect.xMin = lastRect.xMax + UIHelpers.EyeButtonPadding;

                if (item.data.depth == 0 && !item.data.HasChildren)
                {
                    GUI.contentColor = CSColors.labelDimmedColor;
                }
                DefaultGUI.Label(labelRect, args.label, args.selected, args.focused);

                GUI.contentColor = Color.white;
                break;

            case Columns.Component:

                var componentName = item.data.reference.componentName;
                if (!string.IsNullOrEmpty(componentName))
                {
                    DefaultGUI.Label(cellRect, componentName, args.selected, args.focused);
                }

                break;

            case Columns.Property:

                var propertyPath = item.data.reference.propertyPath;
                if (!string.IsNullOrEmpty(propertyPath))
                {
                    DefaultGUI.Label(cellRect, propertyPath, args.selected, args.focused);
                }

                break;

            case Columns.ReferencesCount:

                if (item.depth == 0)
                {
                    DefaultGUI.Label(cellRect, item.data.ChildrenCount.ToString(), args.selected, args.focused);
                }

                break;

            default:
                throw new ArgumentOutOfRangeException("column", column, null);
            }
        }
Ejemplo n.º 11
0
        protected override void DrawCell(ref Rect cellRect, MaintainerTreeViewItem <T> genericItem, int columnValue, RowGUIArgs args)
        {
            base.DrawCell(ref cellRect, genericItem, columnValue, args);

            var column = (Columns)columnValue;
            var item   = (ProjectReferencesTreeViewItem <T>)genericItem;

            switch (column)
            {
            case Columns.Path:

                var entryRect = DrawIconAndGetEntryRect(cellRect, item);

                Rect lastRect;

                var eyeButtonRect = entryRect;
                eyeButtonRect.width  = UIHelpers.EyeButtonSize;
                eyeButtonRect.height = UIHelpers.EyeButtonSize;
                eyeButtonRect.x     += UIHelpers.EyeButtonPadding;

                lastRect = eyeButtonRect;

                if (UIHelpers.IconButton(eyeButtonRect, CSIcons.Show))
                {
                    ShowItem(item);
                }

                if (item.depth == 1 && item.data.isReferenced)
                {
                    var findButtonRect = entryRect;
                    findButtonRect.width  = UIHelpers.EyeButtonSize;
                    findButtonRect.height = UIHelpers.EyeButtonSize;
                    findButtonRect.x     += UIHelpers.EyeButtonPadding * 2 + UIHelpers.EyeButtonSize;

                    lastRect = findButtonRect;

                    if (UIHelpers.IconButton(findButtonRect, CSIcons.Find, "Search for references"))
                    {
                        EditorApplication.delayCall += () => ProjectScopeReferencesFinder.FindAssetReferencesFromResults(item.data.assetPath);
                    }
                }

                var labelRect = entryRect;
                labelRect.xMin = lastRect.xMax + UIHelpers.EyeButtonPadding;

                if (item.data.depth == 0 && !item.data.HasChildren)
                {
                    GUI.contentColor = CSColors.labelDimmedColor;
                }
                DefaultGUI.Label(labelRect, args.label, args.selected, args.focused);

                GUI.contentColor = Color.white;

                break;

            case Columns.Type:

                DefaultGUI.Label(cellRect, item.data.assetTypeName, args.selected, args.focused);
                break;

            case Columns.Size:

                DefaultGUI.Label(cellRect, item.data.assetSizeFormatted, args.selected, args.focused);
                break;

            case Columns.ReferencesCount:

                if (item.depth == 0)
                {
                    DefaultGUI.Label(cellRect, item.data.ChildrenCount.ToString(), args.selected, args.focused);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("column", column, null);
            }
        }
Ejemplo n.º 12
0
        protected override void RowGUI(RowGUIArgs args)
        {
            var wi = WatchRegistry.Watches[args.item.id];

            string value = null;

            if (wi.StringAccessor == null)
            {
                wi.StringAccessor = WatchRegistry.CreateStringAccessor(wi.Watch, wi.Watch);
            }
            if (wi.StringAccessor != null)
            {
                if (!wi.StringAccessor.TryGet(out value))
                {
                    value = "<?>";
                }
            }
            else
            {
                value = $"<No string accessor for type '{wi.Watch.GetValueType().Name}'>";
            }
            for (int iVisCol = 0; iVisCol != args.GetNumVisibleColumns(); ++iVisCol)
            {
                var i    = args.GetColumn(iVisCol);
                var rect = args.GetCellRect(iVisCol);
                switch (i)
                {
                case kColumnIndexName:
                    DefaultGUI.Label(rect, wi.Watch.GetName(), args.selected, args.focused);
                    break;

                case kColumnIndexValue:
                    DefaultGUI.Label(rect, value, args.selected, args.focused);
                    break;

                case kColumnIndexType:
                    DefaultGUI.Label(rect, wi.Watch.GetValueType().Name, args.selected, args.focused);
                    break;

                case kColumnIndexContext:
                    DefaultGUI.Label(rect, wi.Watch.GetContextName(), args.selected, args.focused);
                    break;

                case kColumnIndexVisualization:
                    if (WatchRegistry.WatchTypeRegistry.TryGetTypeInfo(wi.Watch.GetValueType(), out var ti))
                    {
                        GUILayout.BeginArea(rect);
                        GUILayout.BeginHorizontal();
                        foreach (var nameVisFact in ti.Visualizers)
                        {
                            bool hasVis = wi.TryGetWatchVisualizer(nameVisFact.Key, out var vis);
                            if (GUILayout.Toggle(hasVis, new GUIContent(nameVisFact.Key, nameVisFact.Value.GetDescription()), "Button"))
                            {
                                if (!hasVis)
                                {
                                    wi.TryAddVisualizer(nameVisFact.Value, wi.Watch, out vis);
                                }
                            }
                            else
                            {
                                if (hasVis)
                                {
                                    wi.TryRemoveWatchVisualizer(vis);
                                }
                            }
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.EndArea();
                    }
                    break;
                }
            }
        }
Ejemplo n.º 13
0
        private void CellGUI(Rect cellRect, SerializedPropertyItem item, int columnIndex,
                             ref RowGUIArgs args)
        {
            Profiler.BeginSample("SerializedPropertyTreeView.CellGUI");
            CenterRectUsingSingleLineHeight(ref cellRect);
            var data   = item.GetData();
            var column = (Column)multiColumnHeader.GetColumn(columnIndex);

            if (column.drawDelegate == DefaultDelegates.s_DrawName)
            {
                Profiler.BeginSample("SerializedPropertyTreeView.OnItemGUI.LabelField");
                DefaultGUI.Label(cellRect, data.Name, IsSelected(args.item.id), false);
                Profiler.EndSample();
            }
            else if (column.drawDelegate != null)
            {
                var properties = data.Properties;
                var num        = column.dependencyIndices == null ? 0 : column.dependencyIndices.Length;
                for (var i = 0; i < num; i++)
                {
                    m_ColumnsInternal[columnIndex].dependencyProps[i] = properties[column.dependencyIndices[i]];
                }
                if (args.item.id == state.lastClickedID && HasFocus() && columnIndex == multiColumnHeader.state.visibleColumns[multiColumnHeader.state.visibleColumns[0] != 0 ? 0 : 1])
                {
                    GUI.SetNextControlName(Styles.focusHelper);
                }
                var serializedProperty = data.Properties[columnIndex];
                EditorGUI.BeginChangeCheck();
                Profiler.BeginSample("SerializedPropertyTreeView.OnItemGUI.drawDelegate");
                column.drawDelegate(cellRect, serializedProperty, m_ColumnsInternal[columnIndex].dependencyProps);
                Profiler.EndSample();
                if (EditorGUI.EndChangeCheck())
                {
                    m_ChangedId = column.filter == null || !column.filter.Active()
                        ? m_ChangedId
                        : GUIUtility.keyboardControl;
                    data.Store();
                    var selection = GetSelection();
                    if (selection.Contains(data.ObjectId))
                    {
                        var list = FindRows(selection);
                        Undo.RecordObjects((from r in list
                                            select((SerializedPropertyItem)r).GetData()
                                            .SerializedObject.targetObject).ToArray(),
                                           "Modify Multiple Properties");
                        foreach (var current in list)
                        {
                            if (current.id != args.item.id)
                            {
                                var data2 =
                                    ((SerializedPropertyItem)current).GetData();
                                if (IsEditable(data2.SerializedObject.targetObject))
                                {
                                    if (column.copyDelegate != null)
                                    {
                                        column.copyDelegate(data2.Properties[columnIndex], serializedProperty);
                                    }
                                    else
                                    {
                                        DefaultDelegates.s_CopyDefault(data2.Properties[columnIndex],
                                                                       serializedProperty);
                                    }
                                    data2.Store();
                                }
                            }
                        }
                    }
                }
                Profiler.EndSample();
            }
        }
Ejemplo n.º 14
0
        void CellGUI(Rect cellRect, SerializedPropertyItem item, int columnIndex, ref RowGUIArgs args)
        {
            Profiler.BeginSample("SerializedPropertyTreeView.CellGUI");
            CenterRectUsingSingleLineHeight(ref cellRect);
            var    ltd    = item.GetData();
            Column column = (Column)this.multiColumnHeader.GetColumn(columnIndex);

            if (column.drawDelegate == DefaultDelegates.DrawName)
            {
                // default drawing
                Profiler.BeginSample("SerializedPropertyTreeView.OnItemGUI.LabelField");
                using (new EditorGUI.DisabledScope(!ltd.activeInHierarchy))
                {
                    DefaultGUI.Label(cellRect, ltd.name, IsSelected(args.item.id), false);
                }
                Profiler.EndSample();
            }
            else if (column.drawDelegate != null)
            {
                SerializedProperty[] props = ltd.properties;
                int depcnt = column.dependencyIndices != null ? column.dependencyIndices.Length : 0;

                for (int i = 0; i < depcnt; i++)
                {
                    m_ColumnsInternal[columnIndex].dependencyProps[i] = props[column.dependencyIndices[i]];
                }

                // allow to capture tabs
                if (args.item.id == state.lastClickedID && HasFocus() && columnIndex == multiColumnHeader.state.visibleColumns[multiColumnHeader.state.visibleColumns[0] == 0 ? 1 : 0])
                {
                    GUI.SetNextControlName(Styles.focusHelper);
                }

                SerializedProperty prop = ltd.properties[columnIndex];

                EditorGUI.BeginChangeCheck();

                Profiler.BeginSample("SerializedPropertyTreeView.OnItemGUI.drawDelegate");

                column.drawDelegate(cellRect, prop, m_ColumnsInternal[columnIndex].dependencyProps);

                Profiler.EndSample();
                if (EditorGUI.EndChangeCheck())
                {
                    // if we changed a value in a filtered column we'll have to reload the table
                    m_ChangedId = ((column.filter != null) && column.filter.Active()) ? GUIUtility.keyboardControl : m_ChangedId;
                    // update all selected items if the current row was part of the selection list
                    ltd.Store();

                    var selIds = GetSelection();

                    if (selIds.Contains(ltd.objectId))
                    {
                        IList <TreeViewItem> rows = FindRows(selIds);

                        Undo.RecordObjects(rows.Select(r => ((SerializedPropertyItem)r).GetData().serializedObject.targetObject).ToArray(), "Modify Multiple Properties");

                        foreach (var r in rows)
                        {
                            if (r.id == args.item.id)
                            {
                                continue;
                            }

                            var data = ((SerializedPropertyItem)r).GetData();

                            if (!IsEditable(data.serializedObject.targetObject))
                            {
                                continue;
                            }

                            if (column.copyDelegate != null)
                            {
                                column.copyDelegate(data.properties[columnIndex], prop);
                            }
                            else
                            {
                                DefaultDelegates.CopyDefault(data.properties[columnIndex], prop);
                            }

                            data.Store();
                        }
                    }
                }
            }
            Profiler.EndSample();
        }
Ejemplo n.º 15
0
        private void CellGUI(Rect cellRect, ReferencesTreeViewItem <T> item, Columns column, ref RowGUIArgs args)
        {
            baseIndent = item.depth * DepthIndentation;

            CenterRectUsingSingleLineHeight(ref cellRect);

            switch (column)
            {
            case Columns.Path:

                var iconPadding = !Provider.isActive ? 0 : IconPadding;
                var entryRect   = cellRect;

                var num = GetContentIndent(item) + extraSpaceBeforeIconAndLabel;
                entryRect.xMin += num;

                if (item.icon != null)
                {
                    var iconRect = entryRect;
                    iconRect.width  = IconWidth;
                    iconRect.x     += iconPadding;
                    iconRect.height = EditorGUIUtility.singleLineHeight;

                    GUI.DrawTexture(iconRect, item.icon, ScaleMode.ScaleToFit);

                    // BASED ON DECOMPILED CODE
                    // AssetsTreeViewGUI:
                    // float num = (!Provider.isActive) ? 0f : 7f;
                    // iconRightPadding = num;
                    // iconLeftPadding = num;

                    // TreeViewGUI:
                    // iconTotalPadding = iconLeftPadding + iconRightPadding

                    entryRect.xMin +=

                        // TreeViewGUI: public float k_IconWidth = 16f;
                        IconWidth +

                        // TreeViewGUI: iconTotalPadding
                        iconPadding * 2 +

                        // TreeViewGUI: public float k_SpaceBetweenIconAndText = 2f;
                        2f;
                }

                Rect lastRect;

                var eyeButtonRect = entryRect;
                eyeButtonRect.width  = UIHelpers.EyeButtonSize;
                eyeButtonRect.height = UIHelpers.EyeButtonSize;
                eyeButtonRect.x     += UIHelpers.EyeButtonPadding;

                lastRect = eyeButtonRect;

                if (UIHelpers.IconButton(eyeButtonRect, CSIcons.Show))
                {
                    ShowItem(item);
                }

                if (item.depth == 1 && item.data.isReferenced)
                {
                    var findButtonRect = entryRect;
                    findButtonRect.width  = UIHelpers.EyeButtonSize;
                    findButtonRect.height = UIHelpers.EyeButtonSize;
                    findButtonRect.x     += UIHelpers.EyeButtonPadding * 2 + UIHelpers.EyeButtonSize;

                    lastRect = findButtonRect;

                    if (UIHelpers.IconButton(findButtonRect, CSIcons.Find, "Search for references"))
                    {
                        EditorApplication.delayCall += () => ReferencesFinder.FindAssetReferencesFromResults(item.data.assetPath);
                    }
                }

                var labelRect = entryRect;
                labelRect.xMin = lastRect.xMax + UIHelpers.EyeButtonPadding;

                if (item.data.depth == 0 && !item.data.HasChildren)
                {
                    GUI.contentColor = CSColors.labelDimmedColor;
                }
                DefaultGUI.Label(labelRect, args.label, args.selected, args.focused);

                GUI.contentColor = Color.white;

                break;

            case Columns.Type:

                DefaultGUI.Label(cellRect, item.data.assetTypeName, args.selected, args.focused);
                break;

            case Columns.Size:

                DefaultGUI.Label(cellRect, item.data.assetSizeFormatted, args.selected, args.focused);
                break;

            case Columns.ReferencesCount:

                if (item.depth == 0)
                {
                    DefaultGUI.Label(cellRect, item.data.ChildrenCount.ToString(), args.selected, args.focused);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("column", column, null);
            }
        }
Ejemplo n.º 16
0
        void CellGUI(Rect cellRect, TreeViewItem <EditorAssetInfo> item, Columns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);

            if (item.data.IsSelected != args.selected)
            {
                item.data.OnSelected();
                item.data.IsSelected = args.selected;
            }

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

            case Columns.Checker: {
                GUI.DrawTexture(cellRect, item.data.IsAvailable  ? GUIHelper.Textures.CheckMarkOK : GUIHelper.Textures.CheckMaarkNG, ScaleMode.ScaleToFit);
            }
            break;

            case Columns.FileName: {
                var toggleRect = cellRect;
                toggleRect.x    += GetContentIndent(item);
                toggleRect.width = kToggleWidth;

                var build = EditorGUI.Toggle(toggleRect, item.data.IsBuild);           // hide when outside cell rect
                if (item.data.IsBuild != build)
                {
                    UndoHelper.BuilderDataUndo("Check asset");
                    setChildren(item, build);
                }
                //if( item.data.IsDirectoryLabel )
                //    SetExpanded( item.id, false );

                var rect = cellRect;
                rect.x     += GetContentIndent(item) + 15f;
                rect.width -= (GetContentIndent(item) + 15f);
                EditorGUI.BeginDisabledGroup(!item.data.IsBuild);
                DefaultGUI.Label(rect, item.data.Name, args.selected, args.focused);
                EditorGUI.EndDisabledGroup();
            }
            break;

            case Columns.Extension: {
                EditorGUI.BeginDisabledGroup(!item.data.IsBuild);
                DefaultGUI.Label(cellRect, item.data.Extension, args.selected, args.focused);
                EditorGUI.EndDisabledGroup();
            }
            break;

            case Columns.AssetBundleName: {
                if (item.data.IsBuild)
                {
                    var assetBundleName = Config.GetAssetLabel(item.data, BuildRootPath);
                    item.data.AssetBundleName = assetBundleName;
                }
                else
                {
                    if (item.parent != null)
                    {
                        var parent = getAssetInfo(item.parent);
                        item.data.AssetBundleName = parent.data.AssetBundleName;
                    }
                }
                if (!item.data.IsAvailable)
                {
                    break;
                }
                EditorGUI.BeginDisabledGroup(!item.data.IsBuild);
                DefaultGUI.Label(cellRect, item.data.AssetBundleName, args.selected, args.focused);
                EditorGUI.EndDisabledGroup();
            }
            break;

            case Columns.AssetPath: {
                EditorGUI.BeginDisabledGroup(!item.data.IsBuild);
                DefaultGUI.Label(cellRect, item.data.AssetPath, args.selected, args.focused);
                EditorGUI.EndDisabledGroup();
            }
            break;

            case Columns.Guid: {
                EditorGUI.BeginDisabledGroup(!item.data.IsBuild);
                DefaultGUI.Label(cellRect, item.data.Guid, args.selected, args.focused);
                EditorGUI.EndDisabledGroup();
            }
            break;

            case Columns.Version: {
                EditorGUI.BeginDisabledGroup(!item.data.IsBuild);
                if (Config.IsUseAssetBundleList)
                {
                    item.data.Version = item.data.IsBuild ? item.data.OldAssetVersion + 1 : item.data.OldAssetVersion;
                    var version = item.data.Version > 0 ? item.data.Version : 1;
                    DefaultGUI.Label(cellRect, version.ToString(), args.selected, args.focused);

                    var iconRect = cellRect;
                    iconRect.x    += 13;
                    iconRect.width = 30;
                    if (item.data.IsBuild)
                    {
                        GUI.DrawTexture(iconRect, item.data.OldAssetVersion > 0 ? GUIHelper.Textures.VersionUpdate : GUIHelper.Textures.VersionNew, ScaleMode.ScaleToFit);
                    }
                }
                EditorGUI.EndDisabledGroup();
            }
            break;

            case Columns.UnityVersion: {
                EditorGUI.BeginDisabledGroup(!item.data.IsBuild);
                if (Config.IsUseAssetBundleList)
                {
                    DefaultGUI.Label(cellRect, item.data.OldUnityVersion, args.selected, args.focused);
                }
                else
                {
                    DefaultGUI.Label(cellRect, item.data.UnityVersion, args.selected, args.focused);
                }
                EditorGUI.EndDisabledGroup();
            }
            break;
            }
        }
Ejemplo n.º 17
0
            void DrawRowCell(Rect rect, Column column, RootAssemblyViewItem viewItem, RowGUIArgs args)
            {
                CenterRectUsingSingleLineHeight(ref rect);

                switch (column)
                {
                case Column.IncludeInSolutionToggle:
                {
                    var toggleRect  = rect;
                    int toggleWidth = 20;
                    toggleRect.x += rect.width * 0.5f - toggleWidth * 0.5f;

                    bool allChildrenChecked = true;
                    bool anyChildrenChecked = false;
                    foreach (var child in args.item.children)
                    {
                        var buildConfigViewItem = child as ConfigViewItem;
                        if (buildConfigViewItem != null)
                        {
                            allChildrenChecked &= buildConfigViewItem.IncludeInSolution;
                            anyChildrenChecked |= buildConfigViewItem.IncludeInSolution;
                        }
                    }

                    bool isMixed = !allChildrenChecked && anyChildrenChecked;
                    bool originalIncludeAllInSolutionValue = viewItem.IncludeAllInSolution;
                    EditorGUI.showMixedValue = isMixed;
                    var toggleValue = EditorGUI.Toggle(toggleRect, viewItem.IncludeAllInSolution);

                    if (toggleValue != viewItem.IncludeAllInSolution)
                    {
                        viewItem.IncludeAllInSolution = toggleValue;
                        EditorGUI.showMixedValue      = false;

                        // If the parent and children are all selected, and the user de-selects
                        // a child, don't unset all other children, but allow the parent to be listed
                        // as mixed (which is equivalent to false, so setting via toggleValue is no longer ok)
                        if (!(originalIncludeAllInSolutionValue && !toggleValue && isMixed))
                        {
                            foreach (var child in args.item.children)
                            {
                                if (child is ConfigViewItem buildConfigViewItem)
                                {
                                    buildConfigViewItem.IncludeInSolution = toggleValue;
                                }
                            }
                        }

                        Repaint();
                    }
                    else
                    {
                        EditorGUI.showMixedValue = false;

                        if (allChildrenChecked)
                        {
                            viewItem.IncludeAllInSolution = true;
                        }
                    }

                    break;
                }

                case Column.RootGameAssembly:
                {
                    DefaultGUI.Label(rect, viewItem.ProjectName, args.selected, args.focused);
                    break;
                }
                }
            }
Ejemplo n.º 18
0
        void CellGUI(Rect cellRect, TreeViewItem <QuestElement> 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.Icon1:
            //	{
            //		//GUI.DrawTexture(cellRect, s_TestIcons[GetIcon1Index(item)], ScaleMode.ScaleToFit);
            //	}
            //	break;
            //case MyColumns.Icon2:
            //	{
            //		//GUI.DrawTexture(cellRect, s_TestIcons[GetIcon2Index(item)], ScaleMode.ScaleToFit);
            //	}
            //	break;
            case MyColumns.PrimaryKey:
                DefaultGUI.Label(cellRect, item.data.Pk.ToString(), args.selected, args.focused);
                break;

            case MyColumns.OpenAsset:
            {
                Rect buttonRect = cellRect;
                buttonRect.x    += GetContentIndent(item);
                buttonRect.width = 25;

                if (GUI.Button(buttonRect, s_TestIcons[0]))
                {
                    Selection.activeObject = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(item.data.Path);
                }
            }
            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);
                EditorGUI.LabelField(cellRect, item.data.name);
            }
            break;

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

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

            case MyColumns.Active:
            {
                Rect toggleRect = cellRect;
                toggleRect.x    += GetContentIndent(item);
                toggleRect.width = kToggleWidth;
                EditorGUI.Toggle(toggleRect, item.data.Active);
            }
            break;

            case MyColumns.Complete:
            {
                Rect toggleRect = cellRect;
                toggleRect.x    += GetContentIndent(item);
                toggleRect.width = kToggleWidth;
                EditorGUI.Toggle(toggleRect, item.data.Completed);
            }
            break;

            case MyColumns.Delete:
            {
                Rect buttonRect = cellRect;
                buttonRect.x    += GetContentIndent(item);
                buttonRect.width = 55;

                if (GUI.Button(buttonRect, "Delete"))
                {
                    int choice = EditorUtility.DisplayDialogComplex("Delete Quest?",
                                                                    $"Delete both the database entry and local asset OR just the database entry for '{item.data.name}'?", "DB Entry and Asset",
                                                                    "Cancel", "DB Entry Only");

                    if (choice == 1)
                    {
                    }
                    else
                    {
                        var dbPath     = $@"Assets/StreamingAssets/{"quests.db"}";
                        var connection = new SQLiteConnection(dbPath, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create);
                        connection.Delete <QuestEntry>(item.data.Pk);
                        connection.Close();

                        if (choice == 0)                                            // delete both
                        {
                            AssetDatabase.DeleteAsset(item.data.Path);
                        }

                        Repaint();

                        Debug.Log("Deleted");
                    }
                }
            }
            break;

            //case MyColumns.Value1:
            //case MyColumns.Value2:
            //case MyColumns.Value3:
            //	{
            //		if (showControls)
            //		{
            //			cellRect.xMin += 5f; // When showing controls make some extra spacing

            //			if (column == MyColumns.Value1)
            //				item.data.floatValue1 = EditorGUI.Slider(cellRect, GUIContent.none, item.data.floatValue1, 0f, 1f);
            //			if (column == MyColumns.Value2)
            //				item.data.material = (Material)EditorGUI.ObjectField(cellRect, GUIContent.none, item.data.material, typeof(Material), false);
            //			if (column == MyColumns.Value3)
            //				item.data.text = GUI.TextField(cellRect, item.data.text);
            //		}
            //		else
            //		{
            //			string value = "Missing";
            //			if (column == MyColumns.Value1)
            //				value = item.data.floatValue1.ToString("f5");
            //			if (column == MyColumns.Value2)
            //				value = item.data.floatValue2.ToString("f5");
            //			if (column == MyColumns.Value3)
            //				value = item.data.floatValue3.ToString("f5");

            //			DefaultGUI.LabelRightAligned(cellRect, value, args.selected, args.focused);
            //		}
            //	}
            //	break;
            default:
                throw new ArgumentOutOfRangeException(nameof(column), column, null);
            }
        }
Ejemplo n.º 19
0
        private void CellGUI(Rect cellRect, ReferencesTreeViewItem <T> item, Columns column, ref RowGUIArgs args)
        {
            baseIndent = item.depth * DepthIndentation;

            //if (!item.data.exactReferencesExpanded)
            if (item.data.referencingEntries == null)
            {
                CenterRectUsingSingleLineHeight(ref cellRect);
            }
            else
            {
                var lines      = 1 + (item.data.referencingEntries != null ? item.data.referencingEntries.Length : 0);
                var cellHeight = lines * RowHeight;

                if (cellRect.height > cellHeight)
                {
                    cellRect.y     += (cellRect.height - cellHeight) * 0.5f;
                    cellRect.height = cellHeight;
                }

                cellRect.y += MultilineCellYOffset;
            }

            switch (column)
            {
            case Columns.Path:

                var iconPadding = !Provider.isActive ? 0 : IconPadding;
                var entryRect   = cellRect;

                var num = GetContentIndent(item) + extraSpaceBeforeIconAndLabel;
                entryRect.xMin += num;

                if (item.icon != null)
                {
                    var iconRect = entryRect;
                    iconRect.width  = IconWidth;
                    iconRect.x     += iconPadding;
                    iconRect.height = EditorGUIUtility.singleLineHeight;

                    GUI.DrawTexture(iconRect, item.icon, ScaleMode.ScaleToFit);

                    // BASED ON DECOMPILED CODE
                    // AssetsTreeViewGUI:
                    // float num = (!Provider.isActive) ? 0f : 7f;
                    // iconRightPadding = num;
                    // iconLeftPadding = num;

                    // TreeViewGUI:
                    // iconTotalPadding = iconLeftPadding + iconRightPadding

                    entryRect.xMin +=

                        // TreeViewGUI: public float k_IconWidth = 16f;
                        IconWidth +

                        // TreeViewGUI: iconTotalPadding
                        iconPadding * 2 +

                        // TreeViewGUI: public float k_SpaceBetweenIconAndText = 2f;
                        2f;
                }

                var eyeButtonRect = entryRect;
                eyeButtonRect.width  = EyeButtonSize;
                eyeButtonRect.height = EyeButtonSize;
                eyeButtonRect.x     += EyeButtonPadding;

                if (UIHelpers.IconButton(eyeButtonRect, CSIcons.Show))
                {
                    ShowItem(item);
                }

                var labelRect = entryRect;
                labelRect.xMin = eyeButtonRect.xMax + EyeButtonPadding;

                if (item.data.depth == 0 && !item.data.HasChildren)
                {
                    GUI.contentColor = CSColors.labelDimmedColor;
                }
                DefaultGUI.Label(labelRect, args.label, args.selected, args.focused);

                GUI.contentColor = Color.white;

                if (/*item.data.exactReferencesExpanded && */ item.data.referencingEntries != null)
                {
                    var referencingEntriesCount = item.data.referencingEntries.Length;

                    if (referencingEntriesCount > 0)
                    {
                        var warningIconRect = eyeButtonRect;
                        warningIconRect.width  = 16;
                        warningIconRect.height = 16;
                        warningIconRect.x     += 4;

                        var entriesNotFound = item.data.referencingEntries.All(e => e.location == Location.NotFound);

                        var boxRect = entryRect;
                        boxRect.yMin  += RowHeight - 4f;
                        boxRect.height = referencingEntriesCount * RowHeight - 2f;
                        boxRect.xMin   = labelRect.xMin - 2f;

                        GUI.backgroundColor = !entriesNotFound ? CSColors.backgroundGreenTint : CSColors.backgroundRedTint;
                        GUI.Box(boxRect, GUIContent.none);
                        GUI.backgroundColor = Color.white;

                        for (var i = 0; i < referencingEntriesCount; i++)
                        {
                            var entry = item.data.referencingEntries[i];
                            labelRect.y     += RowHeight;
                            eyeButtonRect.y += RowHeight;

                            if (entry.location == Location.NotFound)
                            {
                                warningIconRect.y = eyeButtonRect.y;
                                GUI.DrawTexture(warningIconRect, CSEditorIcons.WarnSmallIcon, ScaleMode.ScaleAndCrop);
                            }
                            else if (entry.location == Location.Invisible)
                            {
                                warningIconRect.y = eyeButtonRect.y;
                                GUI.DrawTexture(warningIconRect, CSEditorIcons.InfoSmallIcon, ScaleMode.ScaleAndCrop);
                            }
                            else if (entry.location == Location.ScriptAsset || entry.location == Location.ScriptableObjectAsset)
                            {
                                //labelRect.xMin = eyeButtonRect.xMax + EyeButtonPadding - eyeButtonRect.width;
                            }
                            else
                            {
                                if (UIHelpers.IconButton(eyeButtonRect, CSIcons.Show))
                                {
                                    ShowItem(item, entry);
                                }
                            }

                            var label = entry.GetLabel();
                            DefaultGUI.Label(labelRect, label, args.selected, args.focused);
                        }
                    }
                }

                break;

            case Columns.Type:

                DefaultGUI.Label(cellRect, item.data.assetTypeName, args.selected, args.focused);
                break;

            case Columns.Size:

                DefaultGUI.Label(cellRect, item.data.assetSizeFormatted, args.selected, args.focused);
                break;

            case Columns.ReferencesCount:

                DefaultGUI.Label(cellRect, item.data.ChildrenCount.ToString(), args.selected, args.focused);
                break;

            default:
                throw new ArgumentOutOfRangeException("column", column, null);
            }
        }
Ejemplo n.º 20
0
        void CellGUI(Rect cellRect, TreeViewItem <EditorAssetInfo> item, Columns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);

            //if( item.data.IsSelected != args.selected ) {
            //    item.data.OnSelected();
            //    item.data.IsSelected = args.selected;
            //}

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

            case Columns.Checker: {
                GUI.DrawTexture(cellRect, item.data.IsAvailable ? GUIHelper.Textures.CheckMarkOK : GUIHelper.Textures.CheckMaarkNG, ScaleMode.ScaleToFit);
            }
            break;

            case Columns.FileName: {
                var toggleRect = cellRect;
                toggleRect.width  = kToggleWidth;
                item.data.IsBuild = EditorGUI.Toggle(toggleRect, item.data.IsBuild);

                var rect = cellRect;
                rect.x     += 15;
                rect.width -= 15;
                DefaultGUI.Label(rect, item.data.Name, args.selected, args.focused);
            }
            break;

            case Columns.AssetBundleName: {
                DefaultGUI.Label(cellRect, item.data.AssetBundleName, args.selected, args.focused);
            }
            break;

            case Columns.AssetPath: {
                DefaultGUI.Label(cellRect, item.data.AssetPath, args.selected, args.focused);
            }
            break;

            case Columns.Extension: {
                DefaultGUI.Label(cellRect, item.data.Extension, args.selected, args.focused);
            }
            break;

            case Columns.Version: {
                if (showControls)
                {
                    cellRect.xMin    += 5f;
                    item.data.Version = EditorGUI.IntField(cellRect, item.data.Version);
                }
                else
                {
                    DefaultGUI.Label(cellRect, item.data.Version.ToString(), args.selected, args.focused);
                }
            }
            break;

            case Columns.Size: {
                DefaultGUI.Label(cellRect, item.data.Size.ToString(), args.selected, args.focused);
            }
            break;

            case Columns.Date: {
                DefaultGUI.Label(cellRect, item.data.Date, args.selected, args.focused);
            }
            break;

            case Columns.UnityVersion: {
                DefaultGUI.Label(cellRect, item.data.UnityVersion, args.selected, args.focused);
            }
            break;
            }
        }
Ejemplo n.º 21
0
 protected void DrawValue(Rect cellRect, string value, bool selected, bool focused)
 {
     DefaultGUI.Label(cellRect, value, selected, focused);
 }
Ejemplo n.º 22
0
        protected override void RowGUI(RowGUIArgs args)
        {
            CenterRectUsingSingleLineHeight(ref args.rowRect);

            var item     = (ExactReferencesListItem <T>)args.item;
            var lastRect = args.rowRect;

            lastRect.xMin += 4;

            if (item.data == null || item.data.entry == null)
            {
                GUI.Label(lastRect, item.displayName);
                return;
            }

            var  entry = item.data.entry;
            Rect iconRect;

            if (entry.location == Location.NotFound)
            {
                iconRect        = lastRect;
                iconRect.width  = UIHelpers.WarningIconSize;
                iconRect.height = UIHelpers.WarningIconSize;

                GUI.DrawTexture(iconRect, CSEditorIcons.WarnSmallIcon, ScaleMode.ScaleToFit);
                lastRect.xMin += UIHelpers.WarningIconSize + UIHelpers.EyeButtonPadding;
            }
            else if (entry.location == Location.Invisible)
            {
                iconRect        = lastRect;
                iconRect.width  = UIHelpers.WarningIconSize;
                iconRect.height = UIHelpers.WarningIconSize;

                GUI.DrawTexture(iconRect, CSEditorIcons.InfoSmallIcon, ScaleMode.ScaleToFit);
                lastRect.xMin += UIHelpers.WarningIconSize + UIHelpers.EyeButtonPadding;
            }
            else
            {
                iconRect        = lastRect;
                iconRect.width  = UIHelpers.EyeButtonSize;
                iconRect.height = UIHelpers.EyeButtonSize;
                if (UIHelpers.IconButton(iconRect, CSIcons.Show))
                {
                    ShowItem(item);
                }
                lastRect.xMin += UIHelpers.EyeButtonSize + UIHelpers.EyeButtonPadding;
            }

            var boxRect = iconRect;

            boxRect.height = lastRect.height;
            boxRect.xMin   = iconRect.xMax;
            boxRect.xMax   = lastRect.xMax;

            GUI.backgroundColor = entry.location != Location.NotFound ? CSColors.backgroundGreenTint : CSColors.backgroundRedTint;
            GUI.Box(boxRect, GUIContent.none);
            GUI.backgroundColor = Color.white;

            var label = entry.GetLabel();

            DefaultGUI.Label(lastRect, label, args.selected, args.focused);
        }
        void CellGUI(Rect cellRect, TreeViewItem <VariablesElement> 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.Id:
            {
                if (editing)
                {
                    EditorGUI.BeginChangeCheck();
                    _variableID = EditorGUI.DelayedTextField(cellRect, item.data.variable.name).Trim().Replace(" ", "").Replace("_", "");
                    if (EditorGUI.EndChangeCheck())
                    {
                        AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(item.data.variable), _variableID);
                    }
                }
                else
                {
                    DefaultGUI.Label(cellRect, item.data.variable.name, args.selected, args.focused);
                }
            }
            break;

            case MyColumns.Group:
            {
                if (editing)
                {
                    EditorGUI.BeginChangeCheck();
                    _variableGroup = EditorGUI.DelayedTextField(cellRect, item.data.variable.group).Trim().Replace(" ", "").Replace("_", "");
                    if (EditorGUI.EndChangeCheck())
                    {
                        item.data.variable.group = _variableGroup;
                    }
                }
                else
                {
                    DefaultGUI.Label(cellRect, item.data.variable.group, args.selected, args.focused);
                }
            }
            break;

            case MyColumns.Type:
                if (editing)
                {
                    EditorGUI.BeginChangeCheck();
                    _variableType = (Variable.VariableType)EditorGUI.EnumPopup(cellRect, item.data.variable.Type);
                    if (EditorGUI.EndChangeCheck())
                    {
                        item.data.variable.Type = _variableType;
                        EditorUtility.SetDirty(item.data.variable);
                    }
                }
                else
                {
                    DefaultGUI.Label(cellRect, item.data.variable.Type.ToString(), args.selected, args.focused);
                }
                break;

            case MyColumns.Default:
            {
                if (editing)
                {
                    EditorGUI.BeginChangeCheck();
                    _serializedVariable = VariableEditor.DrawSerializedVariable(cellRect, item.data.variable.Type, item.data.variable.DefaultValue);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorUtility.SetDirty(item.data.variable);
                    }
                }
                else
                {
                    DefaultGUI.Label(cellRect, item.data.variable.DefaultValue.ToString(), args.selected, args.focused);
                }
            }
            break;

            case MyColumns.InGame:
            {
                if (editing)
                {
                    EditorGUI.BeginChangeCheck();
                    _serializedVariable = VariableEditor.DrawSerializedVariable(cellRect, item.data.variable.Type, item.data.variable.InGameValue);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorUtility.SetDirty(item.data.variable);
                    }
                }
                else
                {
                    DefaultGUI.Label(cellRect, item.data.variable.InGameValue.ToString(), args.selected, args.focused);
                }
            }
            break;


            case MyColumns.Description:
            {
                if (editing)
                {
                    EditorGUI.BeginChangeCheck();
                    _description = EditorGUI.DelayedTextField(cellRect, item.data.variable.description);
                    if (EditorGUI.EndChangeCheck())
                    {
                        item.data.variable.description = _description;
                    }
                }
                else
                {
                    DefaultGUI.Label(cellRect, item.data.variable.description, args.selected, args.focused);
                }
            }
            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;
            }
        }