| | 1 | | // Copyright (c) 2020-2024 dotBunny Inc. |
| | 2 | | // dotBunny licenses this file to you under the BSL-1.0 license. |
| | 3 | | // See the LICENSE file in the project root for more information. |
| | 4 | |
|
| | 5 | | #if !UNITY_DOTSRUNTIME |
| | 6 | |
|
| | 7 | | using UnityEngine; |
| | 8 | | using UnityEngine.Experimental.Rendering; |
| | 9 | |
|
| | 10 | | namespace GDX.Developer.Reports.Resource.Objects |
| | 11 | | { |
| | 12 | | /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception> |
| | 13 | | public sealed class TextureObjectInfo : ObjectInfo |
| | 14 | | { |
| | 15 | | public new const string TypeDefinition = "GDX.Developer.Reports.Resource.Objects.TextureObjectInfo,GDX"; |
| | 16 | | public GraphicsFormat Format; |
| | 17 | | public int Height; |
| | 18 | |
|
| | 19 | | public bool IsReadable; |
| | 20 | | public int Width; |
| | 21 | |
|
| | 22 | | /// <summary> |
| | 23 | | /// Create a clone of this object. |
| | 24 | | /// </summary> |
| | 25 | | /// <returns></returns> |
| | 26 | | public override ObjectInfo Clone() |
| 0 | 27 | | { |
| 0 | 28 | | return new TextureObjectInfo |
| | 29 | | { |
| | 30 | | CopyCount = CopyCount, |
| | 31 | | MemoryUsage = MemoryUsage, |
| | 32 | | Name = Name, |
| | 33 | | Reference = Reference, |
| | 34 | | TotalMemoryUsage = TotalMemoryUsage, |
| | 35 | | Type = Type, |
| | 36 | | Height = Height, |
| | 37 | | IsReadable = IsReadable, |
| | 38 | | Width = Width, |
| | 39 | | Format = Format |
| | 40 | | }; |
| 0 | 41 | | } |
| | 42 | |
|
| | 43 | | public override void Populate(Object targetObject, TransientReference reference = null) |
| 3156 | 44 | | { |
| 3156 | 45 | | base.Populate(targetObject, reference); |
| 3156 | 46 | | Texture textureAsset = (Texture)targetObject; |
| | 47 | |
|
| | 48 | | // Useful texture information |
| 3156 | 49 | | Width = textureAsset.width; |
| 3156 | 50 | | Height = textureAsset.height; |
| 3156 | 51 | | IsReadable = textureAsset.isReadable; |
| 3156 | 52 | | Format = textureAsset.graphicsFormat; |
| 3156 | 53 | | } |
| | 54 | |
|
| | 55 | | public override string GetDetailedInformation(int maximumWidth) |
| 3172 | 56 | | { |
| | 57 | | // Always a width of 11 |
| 3172 | 58 | | string size = $"{Width.ToString()}x{Height.ToString()}".PadRight(11); |
| | 59 | |
|
| 3172 | 60 | | int formatWidth = maximumWidth - 15; |
| 3172 | 61 | | string format = Format.ToString(); |
| 3172 | 62 | | if (format.IsNumeric()) |
| 828 | 63 | | { |
| 828 | 64 | | format = $"Unknown ({format})"; |
| 828 | 65 | | } |
| | 66 | |
|
| 3172 | 67 | | format = format.PadRight(formatWidth); |
| 3172 | 68 | | if (format.Length > formatWidth) |
| 0 | 69 | | { |
| 0 | 70 | | format = format.Substring(0, formatWidth); |
| 0 | 71 | | } |
| | 72 | |
|
| 3172 | 73 | | return $"{size} {format} {(IsReadable ? "RW" : "")}"; |
| 3172 | 74 | | } |
| | 75 | | } |
| | 76 | | } |
| | 77 | | #endif // !UNITY_DOTSRUNTIME |