public static AssetDependencyConfig FindAllAssetData()
        {
            List <string> assetPaths          = new List <string>();
            string        assetDirectory      = PathUtility.GetDiskPath("Assets");
            List <string> assetSubdirectories = new List <string>()
            {
                assetDirectory
            };

            while (assetSubdirectories.Count > 0)
            {
                string dir = assetSubdirectories[0].Replace("\\", "/");
                assetSubdirectories.RemoveAt(0);

                var isIngore = (from folder in IngoreFolders where dir.IndexOf(folder) >= 0 select folder).Any();
                if (isIngore)
                {
                    continue;
                }

                (from file in Directory.GetFiles(dir, "*.*", SearchOption.TopDirectoryOnly)
                 let ext = Path.GetExtension(file).ToLower()
                           where Array.IndexOf(IngoreFileExts, ext) < 0
                           select PathUtility.GetAssetPath(file)
                ).ToList().ForEach((f) => { assetPaths.Add(f); });

                string[] subdirectories = Directory.GetDirectories(dir, "*", SearchOption.TopDirectoryOnly);
                if (subdirectories != null && subdirectories.Length > 0)
                {
                    assetSubdirectories.AddRange(subdirectories);
                }
            }

            AssetDependencyConfig dependencyConfig = new AssetDependencyConfig();

            if (assetPaths.Count > 0)
            {
                for (int i = 0; i < assetPaths.Count; ++i)
                {
                    AssetDependency dependency = new AssetDependency()
                    {
                        assetPath       = assetPaths[i],
                        directlyDepends = AssetDatabaseUtility.GetDirectlyDependencies(assetPaths[i], IngoreFileExts),
                        allDepends      = AssetDatabaseUtility.GetDependencies(assetPaths[i], IngoreFileExts),
                    };

                    dependencyConfig.AddData(dependency);
                }
            }

            string filePath = GetConfigFilePath();

            JSONWriter.WriteToFile(dependencyConfig, filePath);

            return(dependencyConfig);
        }
示例#2
0
 public void AddData(AssetDependency data)
 {
     if (assetDataDic.TryGetValue(data.assetPath, out var adData))
     {
         assetDataDic.Remove(data.assetPath);
         assetDatas.Remove(adData);
     }
     assetDataDic[data.assetPath] = data;
     assetDatas.Add(data);
 }
示例#3
0
        protected override void OnItemDoubleClicked(GridViewData itemData)
        {
            AssetDependency adData = itemData.GetData <AssetDependency>();

            if (adData == null)
            {
                return;
            }
            SelectionUtility.PingObject(adData.assetPath);
        }
示例#4
0
        public override bool HasChild(GridViewData data)
        {
            AssetDependency adData = data.GetData <AssetDependency>();

            if (adData == null)
            {
                return(false);
            }

            return(adData.directlyDepends.Length > 0);
        }
示例#5
0
        public int[] ShowAssets(string[] assetPaths)
        {
            Clear();
            List <int> ids = new List <int>();

            if (assetPaths != null && assetPaths.Length > 0)
            {
                foreach (var assetPath in assetPaths)
                {
                    AssetDependency adData   = dependencyConfig.GetData(assetPath);
                    GridViewData    viewData = new GridViewData(assetPath, adData);
                    AddChildData(RootData, viewData);

                    ids.Add(viewData.ID);
                }
            }
            return(ids.ToArray());
        }
示例#6
0
        protected override void OnDrawRowItem(Rect rect, GridViewData itemData)
        {
            AssetDependency adData = itemData.GetData <AssetDependency>();

            if (adData == null)
            {
                EditorGUI.LabelField(rect, "The data is null");
                return;
            }

            Rect        iconRect = new Rect(rect.x, rect.y, rect.height, rect.height);
            UnityObject assetObj = adData.cachedUObject;

            if (assetObj == null)
            {
                assetObj             = AssetDatabase.LoadAssetAtPath(adData.assetPath, typeof(UnityObject));
                adData.cachedUObject = assetObj;
            }
            Texture2D previewIcon = adData.cachedPreview;

            if (previewIcon == null)
            {
                previewIcon          = EGUIResources.GetAssetPreview(assetObj);
                adData.cachedPreview = previewIcon;
            }
            GUI.DrawTexture(iconRect, previewIcon, ScaleMode.ScaleAndCrop);

            if (Event.current.type == EventType.MouseUp && iconRect.Contains(Event.current.mousePosition))
            {
                SelectionUtility.PingObject(assetObj);
            }

            Rect labelRect = new Rect(iconRect.x + iconRect.width, iconRect.y, rect.width - iconRect.width, iconRect.height);

            EditorGUI.LabelField(labelRect, adData.assetPath, EGUIStyles.MiddleLeftLabelStyle);

            if (assetObj is Texture)
            {
                Rect memorySizeRect = new Rect(rect.x + rect.width - 60, rect.y, 60, rect.height);
                long memorySize     = AssetDatabaseUtility.GetTextureStorageSize(assetObj as Texture);
                EditorGUI.LabelField(memorySizeRect, EditorUtility.FormatBytes(memorySize));
            }
        }
示例#7
0
        protected override void OnDataExpand(GridViewData data)
        {
            if (data.IsExpand)
            {
                return;
            }
            AssetDependency adData = data.GetData <AssetDependency>();

            if (adData.directlyDepends != null && adData.directlyDepends.Length > 0)
            {
                for (int i = 0; i < adData.directlyDepends.Length; ++i)
                {
                    string assetPath = adData.directlyDepends[i];

                    AssetDependency childADData = dependencyConfig.GetData(assetPath);
                    if (childADData == null)
                    {
                        Debug.Log("SSSSSSSSSSS->" + assetPath);
                    }
                    var childData = new GridViewData(assetPath, childADData);
                    AddChildData(data, childData);
                }
            }
        }