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