| | 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 | | { |
| 0 | 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 | | { |
| 53 | 18 | | if (texture == null) |
| 0 | 19 | | return; |
| | 20 | |
|
| 53 | 21 | | texture.wrapMode = textureWrapMode; |
| 53 | 22 | | texture.filterMode = textureFilterMode; |
| | 23 | |
|
| | 24 | | #if !UNITY_STANDALONE |
| | 25 | | texture.Compress(false); |
| | 26 | | #endif |
| | 27 | |
|
| 53 | 28 | | texture.Apply(textureFilterMode != FilterMode.Point, makeNoLongerReadable); |
| 53 | 29 | | } |
| | 30 | |
|
| | 31 | | public override void Cleanup() |
| | 32 | | { |
| 116 | 33 | | OnCleanup?.Invoke(); |
| 116 | 34 | | PersistentAssetCache.RemoveImage(texture); |
| 116 | 35 | | Object.Destroy(texture); |
| 116 | 36 | | } |
| | 37 | |
|
| 0 | 38 | | public void Dispose() { Cleanup(); } |
| | 39 | |
|
| 0 | 40 | | public int width => texture.width; |
| 0 | 41 | | public int height => texture.height; |
| | 42 | | } |
| | 43 | | } |