DrawOverlay() public static method

public static DrawOverlay ( Asset asset, Asset metaAsset, Rect itemRect ) : void
asset UnityEditor.VersionControl.Asset
metaAsset UnityEditor.VersionControl.Asset
itemRect UnityEngine.Rect
return void
Esempio n. 1
0
 public static void OnProjectWindowItem(string guid, Rect drawRect)
 {
     if (!Provider.isActive)
     {
         return;
     }
     Overlay.DrawOverlay(Provider.GetAssetByGUID(guid), drawRect);
 }
Esempio n. 2
0
 public static void OnProjectWindowItem(string guid, Rect drawRect)
 {
     if (Provider.isActive)
     {
         Asset assetByGUID = Provider.GetAssetByGUID(guid);
         if (assetByGUID != null)
         {
             char[] trimChars   = new char[] { '/' };
             Asset  assetByPath = Provider.GetAssetByPath(assetByGUID.path.Trim(trimChars) + ".meta");
             Overlay.DrawOverlay(assetByGUID, assetByPath, drawRect);
         }
     }
 }
        // GUI callback for each item visible in the project window
        public static void OnProjectWindowItem(string guid, Rect drawRect)
        {
            if (!Provider.isActive)
            {
                return;
            }

            Asset asset = Provider.GetAssetByGUID(guid);

            if (asset != null)
            {
                string metaPath  = asset.path.Trim('/') + ".meta";
                Asset  metaAsset = Provider.GetAssetByPath(metaPath);
                Overlay.DrawOverlay(asset, metaAsset, drawRect);
            }
        }
Esempio n. 4
0
        public static void OnProjectWindowItem(string guid, Rect drawRect)
        {
            if (!Provider.isActive)
            {
                return;
            }
            Asset assetByGuid = Provider.GetAssetByGUID(guid);

            if (assetByGuid == null)
            {
                return;
            }
            Asset assetByPath = Provider.GetAssetByPath(assetByGuid.path.Trim('/') + ".meta");

            Overlay.DrawOverlay(assetByGuid, assetByPath, drawRect);
        }
Esempio n. 5
0
        public static void OnProjectWindowItem(string guid, Rect drawRect)
        {
            if (!Provider.isActive)
            {
                return;
            }
            Asset assetByGUID = Provider.GetAssetByGUID(guid);

            if (assetByGUID != null)
            {
                string unityPath = assetByGUID.path.Trim(new char[]
                {
                    '/'
                }) + ".meta";
                Asset assetByPath = Provider.GetAssetByPath(unityPath);
                Overlay.DrawOverlay(assetByGUID, assetByPath, drawRect);
            }
        }
Esempio n. 6
0
 static void HandleVersionControlOverlays(string guid, Rect drawRect)
 {
     if (Provider.isActive)
     {
         string vcsType = VersionControlSettings.mode;
         if (vcsType == ExternalVersionControl.Disabled ||
             vcsType == ExternalVersionControl.AutoDetect ||
             vcsType == ExternalVersionControl.Generic)
         {
             return; // no icons for these version control systems
         }
         Asset asset = Provider.GetAssetByGUID(guid);
         if (asset != null)
         {
             string metaPath  = asset.path.Trim('/') + ".meta";
             Asset  metaAsset = Provider.GetAssetByPath(metaPath);
             Overlay.DrawOverlay(asset, metaAsset, drawRect);
         }
     }
 }
        // GUI callback for each item visible in the project window
        public static void OnProjectWindowItem(string guid, Rect drawRect)
        {
            if (!Provider.isActive)
            {
                return;
            }

            string vcsType = EditorSettings.externalVersionControl;

            if (vcsType == ExternalVersionControl.Disabled ||
                vcsType == ExternalVersionControl.AutoDetect ||
                vcsType == ExternalVersionControl.Generic)
            {
                return; // no icons for these version control systems
            }
            Asset asset = Provider.GetAssetByGUID(guid);

            if (asset != null)
            {
                string metaPath  = asset.path.Trim('/') + ".meta";
                Asset  metaAsset = Provider.GetAssetByPath(metaPath);
                Overlay.DrawOverlay(asset, metaAsset, drawRect);
            }
        }
Esempio n. 8
0
        // Draw a list item.  A few too many magic numbers in here so will need to tidy this a bit
        void DrawItem(ListItem item, Rect area, float x, float y, bool focus, bool selected)
        {
            bool drag      = (item == dragTarget);
            bool highlight = selected;

            if (selected && Event.current.type == EventType.Repaint)
            {
                Styles.evenBackground.Draw(new Rect(area.x, y, area.width, c_lineHeight), GUIContent.none, false, false, true, false);
            }
            else if (drag)
            {
                switch (dragAdjust)
                {
                case SelectDirection.Up:
                    if (item.PrevOpenVisible != item.Parent && Event.current.type == EventType.Repaint)
                    {
                        Styles.dragBackground.Draw(new Rect(x, y - 1, area.width, 2), GUIContent.none, false, false, true, false);
                    }
                    break;

                case SelectDirection.Down:
                    if (Event.current.type == EventType.Repaint)
                    {
                        Styles.dragBackground.Draw(new Rect(x, y - 1, area.width, 2), GUIContent.none, false, false, true, false);
                    }
                    break;

                default:
                    if (item.CanAccept)
                    {
                        if (Event.current.type == EventType.Repaint)
                        {
                            Styles.dragBackground.Draw(new Rect(area.x, y, area.width, c_lineHeight), GUIContent.none, false, false, true, false);
                        }
                        highlight = true;
                    }
                    break;
                }
            }
            else if (dragTarget != null && item == dragTarget.Parent && dragAdjust != SelectDirection.Current)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    Styles.dragBackground.Draw(new Rect(area.x, y, area.width, c_lineHeight), GUIContent.none, false, false, true, false);
                }
                highlight = true;
            }

            if (item.HasActions)
            {
                // Draw any actions available
                for (int i = 0; i < item.Actions.Length; ++i)
                {
                    calcSizeTmpContent.text = item.Actions[i];
                    Vector2 sz = GUI.skin.button.CalcSize(calcSizeTmpContent);
                    if (GUI.Button(new Rect(x, y, sz.x, c_lineHeight), item.Actions[i]))
                    {
                        // Action performed. Callback delegate
                        actionDelegate(item, i);
                    }
                    x += sz.x + 4; // offset by 4 px
                }
            }

            if (item.CanExpand)
            {
                EditorGUI.Foldout(new Rect(x, y, 16, c_lineHeight), item.Expanded, GUIContent.none);
            }

            Texture icon = item.Icon;

            Color tmpColor        = GUI.color;
            Color tmpContentColor = GUI.contentColor;

            // We grey the items when we dont know the state or its a dummy item
            if (/*item.Asset.State == Asset.States.Local ||*/ item.Dummy) //< Locals shown with icon for now
            {
                GUI.color = new Color(0.65f, 0.65f, 0.65f);
            }

            // This should not be an else statement as the previous if can set icon
            if (!item.Dummy)
            {
                // If there is no icon set then we look for cached items
                if (icon == null)
                {
                    icon = InternalEditorUtility.GetIconForFile(item.Name);
                    //                  icon = defaultIcon;
                }

                var iconRect = new Rect(x + 14, y, 16, c_lineHeight);

                if (icon != null)
                {
                    GUI.DrawTexture(iconRect, icon);
                }

                if (item.Asset != null)
                {
                    bool   drawOverlay = true;
                    string vcsType     = EditorSettings.externalVersionControl;
                    if (vcsType == ExternalVersionControl.Disabled ||
                        vcsType == ExternalVersionControl.AutoDetect ||
                        vcsType == ExternalVersionControl.Generic)
                    {
                        drawOverlay = false; // no overlays for these version control systems
                    }
                    if (drawOverlay)
                    {
                        Rect overlayRect = iconRect;
                        overlayRect.width += 12;
                        overlayRect.x     -= 6;
                        Overlay.DrawOverlay(item.Asset, overlayRect);
                    }
                }
            }

            string  displayName     = DisplayName(item);
            Vector2 displayNameSize = EditorStyles.label.CalcSize(EditorGUIUtility.TempContent(displayName));
            float   labelOffsetX    = x + 32;

            if (highlight)
            {
                GUI.contentColor = new Color(3, 3, 3);
                GUI.Label(new Rect(labelOffsetX, y, area.width - labelOffsetX, c_lineHeight + 2), displayName);
            }
            else
            {
                GUI.Label(new Rect(labelOffsetX, y, area.width - labelOffsetX, c_lineHeight + 2), displayName);
            }

            if (HasHiddenMetaFile(item))
            {
                GUI.color = new Color(0.55f, 0.55f, 0.55f);
                float spaceBefore = labelOffsetX + displayNameSize.x + 2;
                GUI.Label(new Rect(spaceBefore, y, area.width - spaceBefore, c_lineHeight + 2), "+meta");
            }
            GUI.contentColor = tmpContentColor;
            GUI.color        = tmpColor;
        }
Esempio n. 9
0
        private static void DrawOverlays(Asset asset, Asset metaAsset, Rect itemRect)
        {
            Overlay.CreateStaticResources();
            float num       = 16f;
            float num2      = 1f;
            float num3      = 4f;
            float num4      = -4f;
            Rect  iconRect  = new Rect(itemRect.x - num2, itemRect.y - num3, num, num);
            Rect  iconRect2 = new Rect(itemRect.xMax - num + num2, itemRect.y - num3, num, num);
            Rect  iconRect3 = new Rect(itemRect.x - num2, itemRect.yMax - num + num3, num, num);
            Rect  iconRect4 = new Rect(itemRect.xMax - num + num4, itemRect.yMax - num + num3, num, num);

            Asset.States states = Asset.States.Local | Asset.States.Synced | Asset.States.ReadOnly | Asset.States.MetaFile;
            bool         flag   = metaAsset == null || (metaAsset.state & states) == states;

            Asset.States states2 = (metaAsset != null) ? (metaAsset.state & (Asset.States.CheckedOutLocal | Asset.States.DeletedLocal | Asset.States.AddedLocal | Asset.States.LockedLocal)) : Asset.States.None;
            Asset.States states3 = (metaAsset != null) ? (metaAsset.state & (Asset.States.CheckedOutRemote | Asset.States.DeletedRemote | Asset.States.AddedRemote | Asset.States.LockedRemote)) : Asset.States.None;
            bool         flag2   = asset.isFolder && Provider.isVersioningFolders;

            if (asset.IsState(Asset.States.AddedLocal))
            {
                Overlay.DrawOverlay(Asset.States.AddedLocal, iconRect);
                if (metaAsset != null && (states2 & Asset.States.AddedLocal) == Asset.States.None && !flag)
                {
                    Overlay.DrawMetaOverlay(iconRect, false);
                }
            }
            else if (asset.IsState(Asset.States.DeletedLocal))
            {
                Overlay.DrawOverlay(Asset.States.DeletedLocal, iconRect);
                if (metaAsset != null && (states2 & Asset.States.DeletedLocal) == Asset.States.None && metaAsset.IsState(Asset.States.Local | Asset.States.Missing))
                {
                    Overlay.DrawMetaOverlay(iconRect, false);
                }
            }
            else if (asset.IsState(Asset.States.LockedLocal))
            {
                Overlay.DrawOverlay(Asset.States.LockedLocal, iconRect);
                if (metaAsset != null && (states2 & Asset.States.LockedLocal) == Asset.States.None && !flag)
                {
                    Overlay.DrawMetaOverlay(iconRect, false);
                }
            }
            else if (asset.IsState(Asset.States.CheckedOutLocal))
            {
                Overlay.DrawOverlay(Asset.States.CheckedOutLocal, iconRect);
                if (metaAsset != null && (states2 & Asset.States.CheckedOutLocal) == Asset.States.None && !flag)
                {
                    Overlay.DrawMetaOverlay(iconRect, false);
                }
            }
            else if (asset.IsState(Asset.States.Local) && !asset.IsState(Asset.States.OutOfSync) && !asset.IsState(Asset.States.Synced))
            {
                Overlay.DrawOverlay(Asset.States.Local, iconRect3);
                if (metaAsset != null && (metaAsset.IsUnderVersionControl || !metaAsset.IsState(Asset.States.Local)))
                {
                    Overlay.DrawMetaOverlay(iconRect3, false);
                }
            }
            else if (metaAsset != null && metaAsset.IsState(Asset.States.AddedLocal))
            {
                Overlay.DrawOverlay(Asset.States.AddedLocal, iconRect);
                if (flag2)
                {
                    Overlay.DrawMetaOverlay(iconRect, false);
                }
            }
            else if (metaAsset != null && metaAsset.IsState(Asset.States.DeletedLocal))
            {
                Overlay.DrawOverlay(Asset.States.DeletedLocal, iconRect);
                if (flag2)
                {
                    Overlay.DrawMetaOverlay(iconRect, false);
                }
            }
            else if (metaAsset != null && metaAsset.IsState(Asset.States.LockedLocal))
            {
                Overlay.DrawOverlay(Asset.States.LockedLocal, iconRect);
                if (flag2)
                {
                    Overlay.DrawMetaOverlay(iconRect, false);
                }
            }
            else if (metaAsset != null && metaAsset.IsState(Asset.States.CheckedOutLocal))
            {
                Overlay.DrawOverlay(Asset.States.CheckedOutLocal, iconRect);
                if (flag2)
                {
                    Overlay.DrawMetaOverlay(iconRect, false);
                }
            }
            else if (metaAsset != null && metaAsset.IsState(Asset.States.Local) && !metaAsset.IsState(Asset.States.OutOfSync) && !metaAsset.IsState(Asset.States.Synced) && !asset.IsState(Asset.States.Conflicted) && (metaAsset == null || !metaAsset.IsState(Asset.States.Conflicted)))
            {
                Overlay.DrawOverlay(Asset.States.Local, iconRect3);
                if (flag2)
                {
                    Overlay.DrawMetaOverlay(iconRect3, false);
                }
            }
            if (asset.IsState(Asset.States.Conflicted) || (metaAsset != null && metaAsset.IsState(Asset.States.Conflicted)))
            {
                Overlay.DrawOverlay(Asset.States.Conflicted, iconRect3);
            }
            if (asset.IsState(Asset.States.AddedRemote))
            {
                Overlay.DrawOverlay(Asset.States.AddedRemote, iconRect2);
                if (metaAsset != null && (states3 & Asset.States.AddedRemote) == Asset.States.None)
                {
                    Overlay.DrawMetaOverlay(iconRect2, true);
                }
            }
            else if (asset.IsState(Asset.States.DeletedRemote))
            {
                Overlay.DrawOverlay(Asset.States.DeletedRemote, iconRect2);
                if (metaAsset != null && (states3 & Asset.States.DeletedRemote) == Asset.States.None)
                {
                    Overlay.DrawMetaOverlay(iconRect2, true);
                }
            }
            else if (asset.IsState(Asset.States.LockedRemote))
            {
                Overlay.DrawOverlay(Asset.States.LockedRemote, iconRect2);
                if (metaAsset != null && (states3 & Asset.States.LockedRemote) == Asset.States.None)
                {
                    Overlay.DrawMetaOverlay(iconRect2, true);
                }
            }
            else if (asset.IsState(Asset.States.CheckedOutRemote))
            {
                Overlay.DrawOverlay(Asset.States.CheckedOutRemote, iconRect2);
                if (metaAsset != null && (states3 & Asset.States.CheckedOutRemote) == Asset.States.None)
                {
                    Overlay.DrawMetaOverlay(iconRect2, true);
                }
            }
            else if (metaAsset != null && metaAsset.IsState(Asset.States.AddedRemote))
            {
                Overlay.DrawOverlay(Asset.States.AddedRemote, iconRect2);
                if (flag2)
                {
                    Overlay.DrawMetaOverlay(iconRect2, true);
                }
            }
            else if (metaAsset != null && metaAsset.IsState(Asset.States.DeletedRemote))
            {
                Overlay.DrawOverlay(Asset.States.DeletedRemote, iconRect2);
                if (flag2)
                {
                    Overlay.DrawMetaOverlay(iconRect2, true);
                }
            }
            else if (metaAsset != null && metaAsset.IsState(Asset.States.LockedRemote))
            {
                Overlay.DrawOverlay(Asset.States.LockedRemote, iconRect2);
                if (flag2)
                {
                    Overlay.DrawMetaOverlay(iconRect2, true);
                }
            }
            else if (metaAsset != null && metaAsset.IsState(Asset.States.CheckedOutRemote))
            {
                Overlay.DrawOverlay(Asset.States.CheckedOutRemote, iconRect2);
                if (flag2)
                {
                    Overlay.DrawMetaOverlay(iconRect2, true);
                }
            }
            if (asset.IsState(Asset.States.OutOfSync) || (metaAsset != null && metaAsset.IsState(Asset.States.OutOfSync)))
            {
                Overlay.DrawOverlay(Asset.States.OutOfSync, iconRect4);
            }
        }
Esempio n. 10
0
        // Draw a list item.  A few too many magic numbers in here so will need to tidy this a bit
        void DrawItem(ListItem item, Rect area, float x, float y, bool focus, bool selected)
        {
            bool drag      = (item == dragTarget);
            bool highlight = selected;

            if (selected && Event.current.type == EventType.Repaint)
            {
                Styles.evenBackground.Draw(new Rect(area.x, y, area.width, c_lineHeight), GUIContent.none, false, false, true, false);
            }
            else if (drag)
            {
                switch (dragAdjust)
                {
                case SelectDirection.Up:
                    if (item.PrevOpenVisible != item.Parent && Event.current.type == EventType.Repaint)
                    {
                        Styles.dragBackground.Draw(new Rect(x, y - 1, area.width, 2), GUIContent.none, false, false, true, false);
                    }
                    break;

                case SelectDirection.Down:
                    if (Event.current.type == EventType.Repaint)
                    {
                        Styles.dragBackground.Draw(new Rect(x, y - 1, area.width, 2), GUIContent.none, false, false, true, false);
                    }
                    break;

                default:
                    if (item.CanAccept || item.Parent.Change != null)
                    {
                        if (Event.current.type == EventType.Repaint)
                        {
                            Styles.dragBackground.Draw(new Rect(area.x, y, area.width, c_lineHeight), GUIContent.none, false, false, true, false);
                        }
                        highlight = true;
                    }
                    break;
                }
            }
            else if (dragTarget != null && item == dragTarget.Parent && dragAdjust != SelectDirection.Current)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    Styles.dragBackground.Draw(new Rect(area.x, y, area.width, c_lineHeight), GUIContent.none, false, false, true, false);
                }
                highlight = true;
            }

            if (item.HasActions)
            {
                // Draw any actions available
                for (int i = 0; i < item.Actions.Length; ++i)
                {
                    calcSizeTmpContent.text = item.Actions[i];
                    Vector2 sz = GUI.skin.button.CalcSize(calcSizeTmpContent);
                    if (GUI.Button(new Rect(x, y, sz.x, c_lineHeight), item.Actions[i]))
                    {
                        // Action performed. Callback delegate
                        actionDelegate(item, i);
                    }
                    x += sz.x + 4; // offset by 4 px
                }
            }

            if (item.CanExpand)
            {
                EditorGUI.Foldout(new Rect(x, y, 16, c_lineHeight), item.Expanded, GUIContent.none);
            }

            Texture icon = item.Icon;

            Color tmpColor        = GUI.color;
            Color tmpContentColor = GUI.contentColor;

            // This should not be an else statement as the previous if can set icon
            if (!item.Dummy || item.Change != null)
            {
                // If there is no icon set then we look for cached items
                if (icon == null)
                {
                    icon = InternalEditorUtility.GetIconForFile(item.Name);
                    //                  icon = defaultIcon;
                }

                var iconRect = new Rect(x + 14, y, 16, c_lineHeight);

                if (selected)
                {
                    Texture activeIcon = EditorUtility.GetIconInActiveState(icon);
                    if (activeIcon != null)
                    {
                        icon = activeIcon;
                    }
                }

                if (icon != null)
                {
                    GUI.DrawTexture(iconRect, icon);
                }

                if (item.Asset != null)
                {
                    bool   drawOverlay = true;
                    string vcsType     = VersionControlSettings.mode;
                    if (vcsType == ExternalVersionControl.Disabled ||
                        vcsType == ExternalVersionControl.AutoDetect ||
                        vcsType == ExternalVersionControl.Generic)
                    {
                        drawOverlay = false; // no overlays for these version control systems
                    }
                    if (drawOverlay)
                    {
                        Rect overlayRect = iconRect;
                        overlayRect.width += 12;
                        overlayRect.x     -= 6;
                        Overlay.DrawOverlay(item.Asset, overlayRect);
                    }
                }
            }

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            GUIStyle label = item.Change != null ? Styles.changeset : Styles.asset;

            string  displayName     = DisplayName(item);
            Vector2 displayNameSize = label.CalcSize(EditorGUIUtility.TempContent(displayName));
            float   labelOffsetX    = x + 32;

            Rect textRect = new Rect(labelOffsetX, y, area.width - labelOffsetX, c_lineHeight + 2);

            int startIndex = -1;

            if (!string.IsNullOrEmpty(filter))
            {
                startIndex = displayName.IndexOf(filter, StringComparison.OrdinalIgnoreCase);
            }

            GUIContent content = new GUIContent(displayName);

            if (item.Dummy)
            {
                GUI.Label(textRect, content, Styles.meta);
            }
            else if (startIndex == -1 || item.Asset == null || Event.current.type != EventType.Repaint)
            {
                label.Draw(textRect, content, false, false, selected, selected);
            }
            else
            {
                int endIndex = startIndex + filter.Length;
                label.DrawWithTextSelection(textRect, content, selected, selected, startIndex, endIndex, false, GUI.skin.settings.selectionColor);
            }

            float spaceBefore       = labelOffsetX + displayNameSize.x + (item.Change != null ? 10 : 2);
            Rect  metaPosition      = new Rect(spaceBefore, y, area.width - spaceBefore, c_lineHeight + 2);
            int   visibleChildCount = item.VisibleChildCount;

            if (HasHiddenMetaFile(item))
            {
                Styles.meta.Draw(metaPosition, GUIContent.Temp("+meta"), false, false, selected, selected);
            }

            if (visibleChildCount > 0)
            {
                Styles.meta.Draw(metaPosition, GUIContent.Temp($"{visibleChildCount} files"), false, false, selected, selected);
            }
        }
Esempio n. 11
0
        private void DrawItem(ListItem item, Rect area, float x, float y, bool focus, bool selected)
        {
            bool flag  = item == this.dragTarget;
            bool flag2 = selected;

            if (selected)
            {
                Texture2D image = (!focus) ? this.greyTex : this.blueTex;
                GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), image, ScaleMode.StretchToFill, false);
            }
            else
            {
                if (flag)
                {
                    ListControl.SelectDirection selectDirection = this.dragAdjust;
                    if (selectDirection != ListControl.SelectDirection.Up)
                    {
                        if (selectDirection != ListControl.SelectDirection.Down)
                        {
                            if (item.CanAccept)
                            {
                                GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), this.yellowTex, ScaleMode.StretchToFill, false);
                                flag2 = true;
                            }
                        }
                        else
                        {
                            GUI.DrawTexture(new Rect(x, y + 16f - 1f, area.width, 2f), this.yellowTex, ScaleMode.StretchToFill, false);
                        }
                    }
                    else
                    {
                        if (item.PrevOpenVisible != item.Parent)
                        {
                            GUI.DrawTexture(new Rect(x, y - 1f, area.width, 2f), this.yellowTex, ScaleMode.StretchToFill, false);
                        }
                    }
                }
                else
                {
                    if (this.dragTarget != null && item == this.dragTarget.Parent && this.dragAdjust != ListControl.SelectDirection.Current)
                    {
                        GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), this.yellowTex, ScaleMode.StretchToFill, false);
                        flag2 = true;
                    }
                }
            }
            if (item.HasActions)
            {
                for (int i = 0; i < item.Actions.Length; i++)
                {
                    this.calcSizeTmpContent.text = item.Actions[i];
                    Vector2 vector = GUI.skin.button.CalcSize(this.calcSizeTmpContent);
                    if (GUI.Button(new Rect(x, y, vector.x, 16f), item.Actions[i]))
                    {
                        this.actionDelegate(item, i);
                    }
                    x += vector.x + 4f;
                }
            }
            if (item.CanExpand)
            {
                EditorGUI.Foldout(new Rect(x, y, 16f, 16f), item.Expanded, GUIContent.none);
            }
            Texture texture      = item.Icon;
            Color   color        = GUI.color;
            Color   contentColor = GUI.contentColor;

            if (item.Dummy)
            {
                GUI.color = new Color(0.65f, 0.65f, 0.65f);
            }
            if (!item.Dummy)
            {
                if (texture == null)
                {
                    texture = InternalEditorUtility.GetIconForFile(item.Name);
                }
                Rect rect = new Rect(x + 14f, y, 16f, 16f);
                if (texture != null)
                {
                    GUI.DrawTexture(rect, texture);
                }
                if (item.Asset != null)
                {
                    Rect itemRect = rect;
                    itemRect.width += 12f;
                    itemRect.x     -= 6f;
                    Overlay.DrawOverlay(item.Asset, itemRect);
                }
            }
            if (flag2)
            {
                GUI.contentColor = new Color(3f, 3f, 3f);
                GUI.Label(new Rect(x + 32f, y, area.width - (x + 32f), 18f), this.DisplayName(item));
            }
            else
            {
                GUI.Label(new Rect(x + 32f, y, area.width - (x + 32f), 18f), this.DisplayName(item));
            }
            GUI.contentColor = contentColor;
            GUI.color        = color;
        }
Esempio n. 12
0
        private void DrawItem(ListItem item, Rect area, float x, float y, bool focus, bool selected)
        {
            bool flag  = item == this.dragTarget;
            bool flag2 = selected;

            if (selected)
            {
                Texture2D image = !focus ? this.greyTex : this.blueTex;
                GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), image, ScaleMode.StretchToFill, false);
            }
            else if (!flag)
            {
                if (((this.dragTarget != null) && (item == this.dragTarget.Parent)) && (this.dragAdjust != SelectDirection.Current))
                {
                    GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), this.yellowTex, ScaleMode.StretchToFill, false);
                    flag2 = true;
                }
            }
            else
            {
                SelectDirection dragAdjust = this.dragAdjust;
                if (dragAdjust == SelectDirection.Up)
                {
                    if (item.PrevOpenVisible != item.Parent)
                    {
                        GUI.DrawTexture(new Rect(x, y - 1f, area.width, 2f), this.yellowTex, ScaleMode.StretchToFill, false);
                    }
                }
                else if (dragAdjust == SelectDirection.Down)
                {
                    GUI.DrawTexture(new Rect(x, (y + 16f) - 1f, area.width, 2f), this.yellowTex, ScaleMode.StretchToFill, false);
                }
                else if (item.CanAccept)
                {
                    GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), this.yellowTex, ScaleMode.StretchToFill, false);
                    flag2 = true;
                }
            }
            if (item.HasActions)
            {
                for (int i = 0; i < item.Actions.Length; i++)
                {
                    this.calcSizeTmpContent.text = item.Actions[i];
                    Vector2 vector = GUI.skin.button.CalcSize(this.calcSizeTmpContent);
                    if (GUI.Button(new Rect(x, y, vector.x, 16f), item.Actions[i]))
                    {
                        this.actionDelegate(item, i);
                    }
                    x += vector.x + 4f;
                }
            }
            if (item.CanExpand)
            {
                EditorGUI.Foldout(new Rect(x, y, 16f, 16f), item.Expanded, GUIContent.none);
            }
            Texture icon         = item.Icon;
            Color   color        = GUI.color;
            Color   contentColor = GUI.contentColor;

            if (item.Dummy)
            {
                GUI.color = new Color(0.65f, 0.65f, 0.65f);
            }
            if (!item.Dummy)
            {
                if (icon == null)
                {
                    icon = InternalEditorUtility.GetIconForFile(item.Name);
                }
                Rect position = new Rect(x + 14f, y, 16f, 16f);
                if (icon != null)
                {
                    GUI.DrawTexture(position, icon);
                }
                if (item.Asset != null)
                {
                    Rect itemRect = position;
                    itemRect.width += 12f;
                    itemRect.x     -= 6f;
                    Overlay.DrawOverlay(item.Asset, itemRect);
                }
            }
            string  t       = this.DisplayName(item);
            Vector2 vector2 = EditorStyles.label.CalcSize(EditorGUIUtility.TempContent(t));
            float   num2    = x + 32f;

            if (flag2)
            {
                GUI.contentColor = new Color(3f, 3f, 3f);
                GUI.Label(new Rect(num2, y, area.width - num2, 18f), t);
            }
            else
            {
                GUI.Label(new Rect(num2, y, area.width - num2, 18f), t);
            }
            if (this.HasHiddenMetaFile(item))
            {
                GUI.color = new Color(0.55f, 0.55f, 0.55f);
                float num3 = (num2 + vector2.x) + 2f;
                GUI.Label(new Rect(num3, y, area.width - num3, 18f), "+meta");
            }
            GUI.contentColor = contentColor;
            GUI.color        = color;
        }
Esempio n. 13
0
        private void DrawItem(ListItem item, Rect area, float x, float y, bool focus, bool selected)
        {
            bool flag1 = item == this.dragTarget;
            bool flag2 = selected;

            if (selected)
            {
                Texture2D texture2D = !focus ? this.greyTex : this.blueTex;
                GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), (Texture)texture2D, ScaleMode.StretchToFill, false);
            }
            else if (flag1)
            {
                switch (this.dragAdjust)
                {
                case ListControl.SelectDirection.Up:
                    if (item.PrevOpenVisible != item.Parent)
                    {
                        GUI.DrawTexture(new Rect(x, y - 1f, area.width, 2f), (Texture)this.yellowTex, ScaleMode.StretchToFill, false);
                        break;
                    }
                    break;

                case ListControl.SelectDirection.Down:
                    GUI.DrawTexture(new Rect(x, (float)((double)y + 16.0 - 1.0), area.width, 2f), (Texture)this.yellowTex, ScaleMode.StretchToFill, false);
                    break;

                default:
                    if (item.CanAccept)
                    {
                        GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), (Texture)this.yellowTex, ScaleMode.StretchToFill, false);
                        flag2 = true;
                        break;
                    }
                    break;
                }
            }
            else if (this.dragTarget != null && item == this.dragTarget.Parent && this.dragAdjust != ListControl.SelectDirection.Current)
            {
                GUI.DrawTexture(new Rect(area.x, y, area.width, 16f), (Texture)this.yellowTex, ScaleMode.StretchToFill, false);
                flag2 = true;
            }
            if (item.HasActions)
            {
                for (int actionIdx = 0; actionIdx < item.Actions.Length; ++actionIdx)
                {
                    this.calcSizeTmpContent.text = item.Actions[actionIdx];
                    Vector2 vector2 = GUI.skin.button.CalcSize(this.calcSizeTmpContent);
                    if (GUI.Button(new Rect(x, y, vector2.x, 16f), item.Actions[actionIdx]))
                    {
                        this.actionDelegate(item, actionIdx);
                    }
                    x += vector2.x + 4f;
                }
            }
            if (item.CanExpand)
            {
                EditorGUI.Foldout(new Rect(x, y, 16f, 16f), item.Expanded, GUIContent.none);
            }
            Texture image        = item.Icon;
            Color   color        = GUI.color;
            Color   contentColor = GUI.contentColor;

            if (item.Dummy)
            {
                GUI.color = new Color(0.65f, 0.65f, 0.65f);
            }
            if (!item.Dummy)
            {
                if ((UnityEngine.Object)image == (UnityEngine.Object)null)
                {
                    image = (Texture)InternalEditorUtility.GetIconForFile(item.Name);
                }
                Rect position = new Rect(x + 14f, y, 16f, 16f);
                if ((UnityEngine.Object)image != (UnityEngine.Object)null)
                {
                    GUI.DrawTexture(position, image);
                }
                if (item.Asset != null)
                {
                    Rect itemRect = position;
                    itemRect.width += 12f;
                    itemRect.x     -= 6f;
                    Overlay.DrawOverlay(item.Asset, itemRect);
                }
            }
            string  str       = this.DisplayName(item);
            Vector2 vector2_1 = EditorStyles.label.CalcSize(EditorGUIUtility.TempContent(str));
            float   x1        = x + 32f;

            if (flag2)
            {
                GUI.contentColor = new Color(3f, 3f, 3f);
                GUI.Label(new Rect(x1, y, area.width - x1, 18f), str);
            }
            else
            {
                GUI.Label(new Rect(x1, y, area.width - x1, 18f), str);
            }
            if (this.HasHiddenMetaFile(item))
            {
                GUI.color = new Color(0.55f, 0.55f, 0.55f);
                float x2 = (float)((double)x1 + (double)vector2_1.x + 2.0);
                GUI.Label(new Rect(x2, y, area.width - x2, 18f), "+meta");
            }
            GUI.contentColor = contentColor;
            GUI.color        = color;
        }
Esempio n. 14
0
        private static void DrawOverlays()
        {
            float num       = 16f;
            float num2      = 1f;
            float num3      = 4f;
            float num4      = -4f;
            Rect  iconRect  = new Rect(Overlay.m_ItemRect.x - num2, Overlay.m_ItemRect.y - num3, num, num);
            Rect  iconRect2 = new Rect(Overlay.m_ItemRect.xMax - num + num2, Overlay.m_ItemRect.y - num3, num, num);
            Rect  iconRect3 = new Rect(Overlay.m_ItemRect.x - num2, Overlay.m_ItemRect.yMax - num + num3, num, num);
            Rect  iconRect4 = new Rect(Overlay.m_ItemRect.xMax - num + num4, Overlay.m_ItemRect.yMax - num + num3, num, num);

            if (Overlay.IsState(Asset.States.AddedLocal))
            {
                Overlay.DrawOverlay(Asset.States.AddedLocal, iconRect);
            }
            else
            {
                if (Overlay.IsState(Asset.States.DeletedLocal))
                {
                    Overlay.DrawOverlay(Asset.States.DeletedLocal, iconRect);
                }
                else
                {
                    if (Overlay.IsState(Asset.States.LockedLocal))
                    {
                        Overlay.DrawOverlay(Asset.States.LockedLocal, iconRect);
                    }
                    else
                    {
                        if (Overlay.IsState(Asset.States.CheckedOutLocal))
                        {
                            Overlay.DrawOverlay(Asset.States.CheckedOutLocal, iconRect);
                        }
                        else
                        {
                            if (Overlay.IsState(Asset.States.Local) && !Overlay.IsState(Asset.States.OutOfSync) && !Overlay.IsState(Asset.States.Synced))
                            {
                                Overlay.DrawOverlay(Asset.States.Local, iconRect3);
                            }
                        }
                    }
                }
            }
            if (Overlay.IsState(Asset.States.Conflicted))
            {
                Overlay.DrawOverlay(Asset.States.Conflicted, iconRect3);
            }
            if (Overlay.IsState(Asset.States.AddedRemote))
            {
                Overlay.DrawOverlay(Asset.States.AddedRemote, iconRect2);
            }
            else
            {
                if (Overlay.IsState(Asset.States.DeletedRemote))
                {
                    Overlay.DrawOverlay(Asset.States.DeletedRemote, iconRect2);
                }
                else
                {
                    if (Overlay.IsState(Asset.States.LockedRemote))
                    {
                        Overlay.DrawOverlay(Asset.States.LockedRemote, iconRect2);
                    }
                    else
                    {
                        if (Overlay.IsState(Asset.States.CheckedOutRemote))
                        {
                            Overlay.DrawOverlay(Asset.States.CheckedOutRemote, iconRect2);
                        }
                    }
                }
            }
            if (Overlay.IsState(Asset.States.OutOfSync))
            {
                Overlay.DrawOverlay(Asset.States.OutOfSync, iconRect4);
            }
        }