예제 #1
0
 // Token: 0x06000127 RID: 295 RVA: 0x00009D74 File Offset: 0x00007F74
 public void Write(bool writeAlways)
 {
     if (!writeAlways && !this._isDirty)
     {
         return;
     }
     if (FileUtil2.Exists(this._cachePath))
     {
         if (FileUtil2.IsReadOnly(this._cachePath))
         {
             this.ShowCacheFileReadOnlyMessage(true);
         }
         if (FileUtil2.IsReadOnly(this._cachePath))
         {
             return;
         }
     }
     using (MemoryStream memoryStream = new MemoryStream(1048576))
     {
         using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
         {
             binaryWriter.Write(322416638u);
             binaryWriter.Write(this._fileVersion);
             List <T> list = new List <T>(this._lut.Values);
             binaryWriter.Write(list.Count);
             BinarySerializer data = new BinarySerializer(binaryWriter);
             foreach (T t in list)
             {
                 t.Serialize(data);
             }
         }
         File.WriteAllBytes(this._cachePath, memoryStream.ToArray());
         this._isDirty = false;
     }
 }
예제 #2
0
        // Token: 0x060000EE RID: 238 RVA: 0x00008F0C File Offset: 0x0000710C
        public static List <string> GetPathsInDirectory(string directory, SearchOption searchOption)
        {
            directory = directory.Replace('\\', '/');
            if (directory[directory.Length - 1] != '/')
            {
                directory += '/';
            }
            List <string> list = new List <string>(64);

            foreach (string text in AssetDatabase.GetAllAssetPaths())
            {
                if (searchOption == SearchOption.AllDirectories)
                {
                    if (text.StartsWith(directory, StringComparison.OrdinalIgnoreCase))
                    {
                        list.Add(text);
                    }
                }
                else if (string.Equals(directory, FileUtil2.GetDirectoryName(text) + '/', StringComparison.OrdinalIgnoreCase))
                {
                    list.Add(text);
                }
            }
            return(list);
        }
예제 #3
0
 // Token: 0x06000124 RID: 292 RVA: 0x00009B30 File Offset: 0x00007D30
 public void Read()
 {
     this._isDirty = false;
     this._lut     = new Dictionary <string, T>();
     try
     {
         if (FileUtil2.Exists(this._cachePath))
         {
             if (FileUtil2.IsReadOnly(this._cachePath))
             {
                 this.ShowCacheFileReadOnlyMessage(false);
             }
             using (MemoryStream memoryStream = new MemoryStream(File.ReadAllBytes(this._cachePath)))
             {
                 using (BinaryReader binaryReader = new BinaryReader(memoryStream))
                 {
                     uint num = binaryReader.ReadUInt32();
                     if (num != 322416638u)
                     {
                         Debug.Log(string.Format("{0}: Cache file '{1}' contains an invalid header magic.", this._appTitle, this._cachePath));
                     }
                     else
                     {
                         int num2 = binaryReader.ReadInt32();
                         if ((long)num2 != (long)((ulong)this._fileVersion))
                         {
                             Debug.Log(string.Format("{0}: Incompatible cache file detected, generating new one. ('{1}').\nThe most likely reason is you upgraded the plugin to a newer version. Existing cache file version is '{2}', required version is '{3}'.", new object[]
                             {
                                 this._appTitle,
                                 this._cachePath,
                                 num2,
                                 this._fileVersion
                             }));
                         }
                         else
                         {
                             BinarySerializer data = new BinarySerializer(binaryReader);
                             int num3 = binaryReader.ReadInt32();
                             for (int i = 0; i < num3; i++)
                             {
                                 T value = (default(T) == null) ? Activator.CreateInstance <T>() : default(T);
                                 value.Serialize(data);
                                 string assetGuid = value.GetAssetGuid();
                                 this._lut[assetGuid] = value;
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Debug.LogError(string.Format("{0}: Could not read cache file '{1}'.\n{2}", this._appTitle, this._cachePath, ex.ToString()));
     }
 }
예제 #4
0
        // Token: 0x06000184 RID: 388 RVA: 0x0000B764 File Offset: 0x00009964
        public static bool IsReadOnly(string assetPath)
        {
            if (!FileUtil2.Exists(assetPath))
            {
                return(false);
            }
            FileInfo fileInfo = new FileInfo(assetPath);

            return(fileInfo.IsReadOnly);
        }
예제 #5
0
        // Token: 0x060000E8 RID: 232 RVA: 0x00008BAC File Offset: 0x00006DAC
        public static Type GetAssetType(string assetPath)
        {
            string fileExtension = FileUtil2.GetFileExtension(assetPath);
            Type   result;

            if (!string.IsNullOrEmpty(fileExtension) && AssetDatabase2._extensionToAssetType.TryGetValue(fileExtension, out result))
            {
                return(result);
            }
            return(null);
        }
예제 #6
0
 // Token: 0x060000F2 RID: 242 RVA: 0x00008FD4 File Offset: 0x000071D4
 public int Compare(string x, string y)
 {
     x = FileUtil2.GetFileName(x);
     y = FileUtil2.GetFileName(y);
     if (string.Compare(x, y, StringComparison.OrdinalIgnoreCase) > 0)
     {
         return(this._greaterResult);
     }
     if (string.Compare(x, y, StringComparison.OrdinalIgnoreCase) < 0)
     {
         return(this._smallerResult);
     }
     return(0);
 }
예제 #7
0
        // Token: 0x06000182 RID: 386 RVA: 0x0000B71C File Offset: 0x0000991C
        public static string GetFileNameWithoutExtension(string assetPath)
        {
            if (string.IsNullOrEmpty(assetPath))
            {
                return("");
            }
            string fileName = FileUtil2.GetFileName(assetPath);
            int    num      = fileName.LastIndexOf('.');

            if (num == -1)
            {
                return(fileName);
            }
            return(fileName.Substring(0, num));
        }
예제 #8
0
        // Token: 0x06000155 RID: 341 RVA: 0x0000A8E0 File Offset: 0x00008AE0
        public static void PathLabel(Rect position, string text, bool selected, Color selectedColor, GUIStyle selectedStyle, Color unselectedColor, GUIStyle unselectedStyle)
        {
            string text2 = text;
            Color  color = GUI.color;

            GUI.color = (selected ? selectedColor : unselectedColor);
            int num = 0;

            for (;;)
            {
                num++;
                if (num >= 5 || EditorStyles.label.CalcSize(GUIContent2.Temp(text)).x <= position.width)
                {
                    goto IL_158;
                }
                text = text.Replace("/.../", "/");
                int num2 = text.LastIndexOf('/');
                if (num2 == -1)
                {
                    break;
                }
                int num3 = text.LastIndexOf('/', num2 - 1);
                if (num3 == -1)
                {
                    break;
                }
                string str  = text.Substring(num2 + 1);
                string str2 = text.Substring(0, num3);
                text = str2 + "/.../" + str;
            }
            text = ".../" + FileUtil2.GetFileName(text2);
            if (EditorStyles.label.CalcSize(GUIContent2.Temp(text)).x > position.width)
            {
                Rect rect = position;
                rect.x         += rect.width - 18f;
                rect.width      = 16f;
                position.width -= rect.width;
                GUI.Label(position, GUIContent2.Temp(text, text2), selected ? selectedStyle : unselectedStyle);
                GUI.Label(rect, GUIContent2.Temp("...", text2), selected ? selectedStyle : unselectedStyle);
                goto IL_179;
            }
            GUI.Label(position, GUIContent2.Temp(text), selected ? selectedStyle : unselectedStyle);
            goto IL_179;
IL_158:
            GUI.Label(position, GUIContent2.Temp(text, (num > 1) ? text2 : ""), selected ? selectedStyle : unselectedStyle);
IL_179:
            GUI.color = color;
        }
예제 #9
0
            // Token: 0x060001A8 RID: 424 RVA: 0x0000C810 File Offset: 0x0000AA10
            protected override void OnItemContextMenu(GUIListViewContextMenuArgs args)
            {
                base.OnItemContextMenu(args);
                if (base.SelectedItemsCount < 1)
                {
                    return;
                }
                FindAssetUsage.AssetProxy assetProxy = args.Model as FindAssetUsage.AssetProxy;
                bool        flag        = FileUtil2.Exists(assetProxy.AssetPath);
                GenericMenu genericMenu = new GenericMenu();

                genericMenu.AddItem(new GUIContent((Application.platform == null) ? "Reveal in Finder" : "Show in Explorer"), false, flag ? new GenericMenu.MenuFunction(this.OnContextMenuShowInExplorer) : null);
                genericMenu.AddItem(new GUIContent("Open %enter"), false, FileUtil2.Exists(assetProxy.AssetPath) ? new GenericMenu.MenuFunction(this.OnContextMenuOpenWithDefaultApp) : null);
                genericMenu.AddItem(new GUIContent(string.Empty), false, null);
                genericMenu.AddItem(new GUIContent("Select in Project _enter"), false, flag ? new GenericMenu.MenuFunction(this.OnContextMenuSelect) : null);
                genericMenu.AddItem(new GUIContent("Find References in Scene"), false, (base.SelectedItemsCount == 1) ? new GenericMenu.MenuFunction(this.OnContextMenuFindReferencesInScene) : null);
                genericMenu.AddItem(new GUIContent(string.Empty), false, null);
                genericMenu.AddItem(new GUIContent("Copy Full Path"), false, flag ? new GenericMenu.MenuFunction(this.OnContextMenuCopyFullPath) : null);
                genericMenu.DropDown(new Rect(args.MenuLocation.x, args.MenuLocation.y, 0f, 0f));
                Event.current.Use();
                base.Editor.Repaint();
            }
예제 #10
0
        // Token: 0x06000187 RID: 391 RVA: 0x0000BA4C File Offset: 0x00009C4C
        public static FindAssetUsage.Result InProject(IEnumerable <Object> findobjs, IEnumerable <Type> findtypes)
        {
            EditorUtility2.UnloadUnusedAssetsImmediate();
            Dictionary <Object, Dictionary <string, string> > dictionary = new Dictionary <Object, Dictionary <string, string> >();

            foreach (Object @object in findobjs)
            {
                if (@object != null && !dictionary.ContainsKey(@object))
                {
                    dictionary.Add(@object, new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase));
                }
            }
            string text = "";

            foreach (Type type in findtypes)
            {
                if (!string.IsNullOrEmpty(text))
                {
                    text += ", ";
                }
                text += type.Name;
            }
            using (EditorGUI2.ModalProgressBar modalProgressBar = new EditorGUI2.ModalProgressBar(string.Format("Searching {0} assets...", text), true))
            {
                List <string> pathsByType = AssetDatabase2.GetPathsByType(findtypes);
                for (int i = 0; i < pathsByType.Count; i++)
                {
                    string text2 = pathsByType[i];
                    if (modalProgressBar.TotalElapsedTime > 1f && modalProgressBar.ElapsedTime > 0.1f)
                    {
                        float  progress = (float)i / (float)pathsByType.Count;
                        string text3    = string.Format("[{1} remaining] {0}", FileUtil2.GetFileNameWithoutExtension(text2), pathsByType.Count - i - 1);
                        if (modalProgressBar.Update(text3, progress))
                        {
                            break;
                        }
                    }
                    Object   object2 = AssetDatabase.LoadMainAssetAtPath(text2);
                    Object[] array   = EditorUtility.CollectDependencies(new Object[]
                    {
                        object2
                    });
                    foreach (Object object3 in array)
                    {
                        Dictionary <string, string> dictionary2;
                        if (!(object3 == null) && dictionary.TryGetValue(object3, out dictionary2))
                        {
                            dictionary2[text2] = text2;
                        }
                    }
                    if (i % 25 == 0)
                    {
                        EditorUtility2.UnloadUnusedAssetsImmediate();
                    }
                }
            }
            FindAssetUsage.Result result = new FindAssetUsage.Result();
            foreach (KeyValuePair <Object, Dictionary <string, string> > keyValuePair in dictionary)
            {
                FindAssetUsage.ResultEntry resultEntry = new FindAssetUsage.ResultEntry();
                resultEntry.Asset = keyValuePair.Key;
                foreach (KeyValuePair <string, string> keyValuePair2 in keyValuePair.Value)
                {
                    resultEntry.Add(keyValuePair2.Key);
                }
                result.Entries.Add(resultEntry);
            }
            return(result);
        }
예제 #11
0
        // Token: 0x06000186 RID: 390 RVA: 0x0000B7BC File Offset: 0x000099BC
        public static FindAssetUsage.Result InProject(IEnumerable <string> findpaths, IEnumerable <Type> findtypes)
        {
            EditorUtility2.UnloadUnusedAssetsImmediate();
            Dictionary <string, Dictionary <string, string> > dictionary = new Dictionary <string, Dictionary <string, string> >();

            foreach (string text in findpaths)
            {
                if (!string.IsNullOrEmpty(text) && !dictionary.ContainsKey(text))
                {
                    dictionary.Add(text, new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase));
                }
            }
            string text2 = "";

            foreach (Type type in findtypes)
            {
                if (!string.IsNullOrEmpty(text2))
                {
                    text2 += ", ";
                }
                text2 += type.Name;
            }
            using (EditorGUI2.ModalProgressBar modalProgressBar = new EditorGUI2.ModalProgressBar(string.Format("Searching {0} assets...", text2), true))
            {
                List <string> pathsByType = AssetDatabase2.GetPathsByType(findtypes);
                for (int i = 0; i < pathsByType.Count; i++)
                {
                    string text3 = pathsByType[i];
                    if (modalProgressBar.TotalElapsedTime > 1f && modalProgressBar.ElapsedTime > 0.1f)
                    {
                        float  progress = (float)i / (float)pathsByType.Count;
                        string text4    = string.Format("[{1} remaining] {0}", FileUtil2.GetFileNameWithoutExtension(text3), pathsByType.Count - i - 1);
                        if (modalProgressBar.Update(text4, progress))
                        {
                            break;
                        }
                    }
                    string[] dependencies = AssetDatabase.GetDependencies(new string[]
                    {
                        text3
                    });
                    foreach (string text5 in dependencies)
                    {
                        Dictionary <string, string> dictionary2;
                        if (!string.Equals(text5, text3, StringComparison.OrdinalIgnoreCase) && dictionary.TryGetValue(text5, out dictionary2))
                        {
                            dictionary2[text3] = text3;
                        }
                    }
                }
            }
            FindAssetUsage.Result result = new FindAssetUsage.Result();
            foreach (KeyValuePair <string, Dictionary <string, string> > keyValuePair in dictionary)
            {
                FindAssetUsage.ResultEntry resultEntry = new FindAssetUsage.ResultEntry();
                resultEntry.AssetPath = keyValuePair.Key;
                foreach (KeyValuePair <string, string> keyValuePair2 in keyValuePair.Value)
                {
                    resultEntry.Add(keyValuePair2.Key);
                }
                result.Entries.Add(resultEntry);
            }
            return(result);
        }