Ejemplo n.º 1
0
 public void RefreshDependencies()
 {
     if (_setting_useDependencyChecker)
     {
         DependencyChecker.Refresh();
     }
 }
Ejemplo n.º 2
0
        private void Update()
        {
            if (_setting_useDependencyChecker)
            {
                if (DependencyChecker.Running)
                {
                    DependencyChecker.Continue();
                }
            }

            if (!_setting_showHoverPreview)
            {
                return;
            }

            if (_lastGUID == null && _currentGUID == null)
            {
                return;
            }

            if (_lastGUID != _currentGUID)
            {
                _lastGUID = _currentGUID;

                TeneEnhPreviewWindow.Update(
                    Common.ProjectWindow.position,
                    _mousePosition,
                    pGUID: _currentGUID
                    );
            }
            else
            {
                _updateThrottle++;
                if (_updateThrottle > 20)
                {
                    _currentGUID = null;
                    Common.ProjectWindow.Repaint();
                    _updateThrottle = 0;
                }
            }
        }
Ejemplo n.º 3
0
        public override void OnEnable()
        {
            EditorApplication.projectWindowItemOnGUI -= Draw;
            EditorApplication.projectWindowItemOnGUI += Draw;

            EditorApplication.update -= Update;
            EditorApplication.update += Update;

            if (EditorGUIUtility.isProSkin)
            {
                _colorMap = new Dictionary <string, Color>()
                {
                    { "png", new Color(0.8f, 0.8f, 1.0f) },
                    { "psd", new Color(0.5f, 0.8f, 1.0f) },
                    { "tga", new Color(0.8f, 0.5f, 1.0f) },

                    { "cs", new Color(0.5f, 1.0f, 0.5f) },
                    { "js", new Color(0.8f, 1.0f, 0.3f) },
                    { "boo", new Color(0.3f, 1.0f, 0.8f) },

                    { "mat", new Color(1.0f, 0.8f, 0.8f) },
                    { "shader", new Color(1.0f, 0.5f, 0.5f) },

                    { "wav", new Color(0.8f, 0.4f, 1.0f) },
                    { "mp3", new Color(0.8f, 0.4f, 1.0f) },
                    { "ogg", new Color(0.8f, 0.4f, 1.0f) },
                }
            }
            ;
            else
            {
                _colorMap = new Dictionary <string, Color>()
                {
                    { "png", new Color(0.0f, 0.0f, 1.0f) },
                    { "psd", new Color(0.7f, 0.2f, 1.0f) },
                    { "tga", new Color(0.2f, 0.7f, 1.0f) },

                    { "cs", new Color(0.0f, 0.5f, 0.0f) },
                    { "js", new Color(0.5f, 0.5f, 0.0f) },
                    { "boo", new Color(0.0f, 0.5f, 0.5f) },

                    { "mat", new Color(0.2f, 0.8f, 0.8f) },
                    { "shader", new Color(1.0f, 0.5f, 0.5f) },

                    { "wav", new Color(0.8f, 0.4f, 1.0f) },
                    { "mp3", new Color(0.8f, 0.4f, 1.0f) },
                    { "ogg", new Color(0.8f, 0.4f, 1.0f) },
                }
            };

            //_specialPaths = new Dictionary<string, string>()
            //{
            //    {"WebPlayerTemplates", "WebPlayerTemplates - excluded from build"}
            //};

            _needHackScrollbarWidthForDrawing = Common.UnityVersion() < Common.UnityVersion("4.0.0b8");

            ReadSettings();

            if (File.Exists(Common.TempRecompilationList))
            {
                CheckScriptInfo(File.ReadAllText(Common.TempRecompilationList));
                File.Delete(Common.TempRecompilationList);
            }

            //SetProjectWindowFoldersFirst( _setting_showFoldersFirst );

            if (Common.ProjectWindow != null)
            {
                Common.ProjectWindow.Repaint();
            }

            if (_setting_useDependencyChecker)
            {
                DependencyChecker.Refresh();
            }
        }//
Ejemplo n.º 4
0
        private void Draw(string pGUID, Rect pDrawingRect)
        {
            // called per-line in the project window

            // if we're drawing at a higher position from the last time, then
            // assume we're drawing from the top again and clear stuff we might
            // need to clear
            if (pDrawingRect.y < _lastY)
            {
                DrawingStarted();
            }

            _lastY = pDrawingRect.y;


            // now process the asset

            string assetpath = AssetDatabase.GUIDToAssetPath(pGUID);

            if (assetpath.Length == 0)
            {
                return;
            }

            string extension = Path.GetExtension(assetpath);
            string filename  = Path.GetFileNameWithoutExtension(assetpath);
            bool   isFolder  = false;

            bool icons = pDrawingRect.height > 20;

            string path = Path.GetDirectoryName(assetpath);

#if UNITY_2018
            // Exclude PackageManager "Packages" folder
            if (path.Contains("Packages"))
            {
                return;
            }
#endif

            isFolder = (GetFileAttr(assetpath) & FileAttributes.Directory) != 0;

            if (_setting_useDependencyChecker && !isFolder && !DependencyChecker.IsUsed(assetpath))
            {
                Color c = GUI.color;
                GUI.color = new Color(1, 0, 0, 0.1f);
                Rect r = pDrawingRect;
                r.width += r.x;
                r.x      = 0;
                GUI.DrawTexture(r, EditorGUIUtility.whiteTexture);
                GUI.color = c;
            }

            bool doPreview = Common.Modifier(_setting_showHoverPreview, _setting_showHoverPreviewShift, _setting_showHoverPreviewCtrl, _setting_showHoverPreviewAlt);
            bool doTooltip = Common.Modifier(_setting_showHoverTooltip, _setting_showHoverTooltipShift, _setting_showHoverTooltipCtrl, _setting_showHoverTooltipAlt);

            if (doTooltip)
            {
                string tooltip = GetTooltip(assetpath);
                if (tooltip.Length > 0)
                {
                    GUI.Label(pDrawingRect, new GUIContent(" ", tooltip));
                }
            }

            if (!_setting_showFileCount && isFolder)
            {
                return;
            }

            _mousePosition = new Vector2(Event.current.mousePosition.x + Common.ProjectWindow.position.x, Event.current.mousePosition.y + Common.ProjectWindow.position.y);

#if UNITY_4_PLUS
            if (Event.current.mousePosition.x < pDrawingRect.width - 16)
#endif
            if (doPreview)
            {
                if (pDrawingRect.Contains(Event.current.mousePosition))
                {
                    _currentGUID = pGUID;
                }
            }

            if (!isFolder)
            {
                if (_setting_showExtensionsWhen == ShowExtensions.Never)
                {
                    return;
                }
                else if (_setting_showExtensionsWhen == ShowExtensions.OnlyWhenConflicts)
                {
                    if (GetExtensionsCount(extension, filename, path) <= 1)
                    {
                        return;
                    }
                }
            }

            GUIStyle labelstyle;

            if (_setting_showExtensionsFilename)
            {
                labelstyle = icons ? new GUIStyle(EditorStyles.miniLabel) : new GUIStyle(EditorStyles.label);
                Rect extRect = pDrawingRect;
                extRect.x += labelstyle.CalcSize(new GUIContent(filename)).x + 15;
                extRect.y++;

                if (!isFolder)
                {
                    if (!_GUIDsToIgnore.Contains(pGUID))
                    {
                        GUI.Label(extRect, extension);
                        _GUIDsToIgnore.Add(pGUID);
                    }
                }

                return;
            }

            Color  labelColor    = Color.grey;
            string drawextension = "";

            if (!isFolder)
            {
                if (extension != "")
                {
                    extension     = extension.Substring(1);
                    drawextension = extension;
                }

                if (!_colorMap.TryGetValue(extension.ToLower(), out labelColor))
                {
                    labelColor = Color.grey;
                }
            }
            else
            {
                labelColor = new Color(0.75f, 0.75f, 0.75f, 1.0f);
                int files = GetFolderFilesCount(assetpath);
                if (files == 0)
                {
                    return;
                }
                drawextension = "(" + files + ")";
            }

            labelstyle = icons ? Common.ColorMiniLabel(labelColor) : Common.ColorLabel(labelColor);
            Rect    newRect   = pDrawingRect;
            Vector2 labelSize = labelstyle.CalcSize(new GUIContent(drawextension));

            if (icons)
            {
                labelSize      = labelstyle.CalcSize(new GUIContent(drawextension));
                newRect.x     += newRect.width - labelSize.x;
                newRect.width  = labelSize.x;
                newRect.height = labelSize.y;
            }
            else
            {
#if UNITY_4_PLUS
                newRect.width += pDrawingRect.x - (_needHackScrollbarWidthForDrawing ? 16 : 0);
                newRect.x      = 0;
#else
                newRect.width += pDrawingRect.x;
                newRect.x      = 0;
#endif
                newRect.x = newRect.width - labelSize.x;
                if (!isFolder)
                {
                    newRect.x -= 4;

                    if (drawextension != "")
                    {
                        drawextension = "." + drawextension;
                    }
                }

                labelSize = labelstyle.CalcSize(new GUIContent(drawextension));

                newRect.width = labelSize.x + 1;

                if (isFolder)
                {
                    newRect    = pDrawingRect;
                    newRect.x += labelstyle.CalcSize(new GUIContent(filename)).x + 20;
                }
            }

            Color color = GUI.color;

            if (!isFolder || icons)
            {
                // fill background
                Color bgColor = Common.DefaultBackgroundColor;
                if (drawextension != "")
                {
                    bgColor.a = 1;
                }
                else
                {
                    bgColor.a = 0;
                }
                GUI.color = bgColor;
                GUI.DrawTexture(newRect, EditorGUIUtility.whiteTexture);
            }

            GUI.color = labelColor;
            GUI.Label(newRect, drawextension, labelstyle);
            GUI.color = color;
        }