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