| | 1 | | using UnityEngine; |
| | 2 | | using Object = UnityEngine.Object; |
| | 3 | |
|
| | 4 | | namespace DCL |
| | 5 | | { |
| | 6 | | public class Asset_Texture : Asset, ITexture |
| | 7 | | { |
| 1222 | 8 | | public Texture2D texture { get; set; } |
| 127 | 9 | | public float resizingFactor = 1; |
| | 10 | | public Asset_Texture dependencyAsset; // to store the default tex asset and release it accordingly |
| | 11 | | public event System.Action OnCleanup; |
| | 12 | |
|
| | 13 | | public void ConfigureTexture(TextureWrapMode textureWrapMode, FilterMode textureFilterMode, bool? overrideCompre |
| | 14 | | { |
| 105 | 15 | | if (texture == null) |
| 1 | 16 | | return; |
| | 17 | |
|
| 104 | 18 | | texture.wrapMode = textureWrapMode; |
| 104 | 19 | | texture.filterMode = textureFilterMode; |
| | 20 | |
|
| 104 | 21 | | if (overrideCompression ?? DataStore.i.textureConfig.runCompression.Get()) |
| 0 | 22 | | texture.Compress(false); |
| | 23 | |
|
| 104 | 24 | | texture.Apply(textureFilterMode != FilterMode.Point, makeNoLongerReadable); |
| 104 | 25 | | } |
| | 26 | |
|
| | 27 | | public override void Cleanup() |
| | 28 | | { |
| 134 | 29 | | OnCleanup?.Invoke(); |
| 134 | 30 | | OnCleanup = null; |
| | 31 | |
|
| 134 | 32 | | Object.Destroy(texture); |
| 134 | 33 | | if (this.texture != null) |
| 104 | 34 | | Object.Destroy(this.texture); |
| 134 | 35 | | this.texture = null; |
| | 36 | |
|
| 134 | 37 | | dependencyAsset = null; |
| 134 | 38 | | } |
| | 39 | |
|
| 0 | 40 | | public void Dispose() { Cleanup(); } |
| | 41 | |
|
| 0 | 42 | | public int width => texture.width; |
| 0 | 43 | | public int height => texture.height; |
| | 44 | | } |
| | 45 | | } |