A game about forced loneliness, made by TACStudios
at master 91 lines 3.1 kB view raw
1using System; 2 3namespace UnityEngine.Rendering 4{ 5 /// <summary> 6 /// Attribute specifying information to reload with <see cref="ResourceReloader"/>. This is only 7 /// used in the editor and doesn't have any effect at runtime. 8 /// </summary> 9 /// <seealso cref="ResourceReloader"/> 10 /// <seealso cref="ReloadGroupAttribute"/> 11 [AttributeUsage(AttributeTargets.Field)] 12 public sealed class ReloadAttribute : Attribute 13 { 14 /// <summary> 15 /// Lookup method for a resource. 16 /// </summary> 17 public enum Package 18 { 19 /// <summary> 20 /// Used for builtin resources when the resource isn't part of the package (i.e. builtin 21 /// shaders). 22 /// </summary> 23 Builtin, 24 25 /// <summary> 26 /// Used for resources inside the package. 27 /// </summary> 28 Root, 29 30 /// <summary> 31 /// Used for builtin extra resources when the resource isn't part of the package (i.e. builtin 32 /// extra Sprite). 33 /// </summary> 34 BuiltinExtra, 35 }; 36 37#if UNITY_EDITOR 38 /// <summary> 39 /// The lookup method. 40 /// </summary> 41 public readonly Package package; 42 43 /// <summary> 44 /// Search paths. 45 /// </summary> 46 public readonly string[] paths; 47#endif 48 49 /// <summary> 50 /// Creates a new <see cref="ReloadAttribute"/> for an array by specifying each resource 51 /// path individually. 52 /// </summary> 53 /// <param name="paths">Search paths</param> 54 /// <param name="package">The lookup method</param> 55 public ReloadAttribute(string[] paths, Package package = Package.Root) 56 { 57#if UNITY_EDITOR 58 this.paths = paths; 59 this.package = package; 60#endif 61 } 62 63 /// <summary> 64 /// Creates a new <see cref="ReloadAttribute"/> for a single resource. 65 /// </summary> 66 /// <param name="path">Search path</param> 67 /// <param name="package">The lookup method</param> 68 public ReloadAttribute(string path, Package package = Package.Root) 69 : this(new[] { path }, package) 70 { } 71 72 /// <summary> 73 /// Creates a new <see cref="ReloadAttribute"/> for an array using automatic path name 74 /// numbering. 75 /// </summary> 76 /// <param name="pathFormat">The format used for the path</param> 77 /// <param name="rangeMin">The array start index (inclusive)</param> 78 /// <param name="rangeMax">The array end index (exclusive)</param> 79 /// <param name="package">The lookup method</param> 80 public ReloadAttribute(string pathFormat, int rangeMin, int rangeMax, 81 Package package = Package.Root) 82 { 83#if UNITY_EDITOR 84 this.package = package; 85 paths = new string[rangeMax - rangeMin]; 86 for (int index = rangeMin, i = 0; index < rangeMax; ++index, ++i) 87 paths[i] = string.Format(pathFormat, index); 88#endif 89 } 90 } 91}