| | 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 | |
|
| | 9 | | namespace GDX.Developer.Reports.Resource.Objects |
| | 10 | | { |
| | 11 | | /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception> |
| | 12 | | public sealed class MeshObjectInfo : ObjectInfo |
| | 13 | | { |
| | 14 | | public new const string TypeDefinition = "GDX.Developer.Reports.Resource.Objects.MeshObjectInfo,GDX"; |
| | 15 | | public bool IsReadable; |
| | 16 | | public int SubMeshCount; |
| | 17 | | public int Triangles; |
| | 18 | |
|
| | 19 | | public int VertexCount; |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// Create a clone of this object. |
| | 23 | | /// </summary> |
| | 24 | | /// <returns></returns> |
| | 25 | | public override ObjectInfo Clone() |
| 0 | 26 | | { |
| 0 | 27 | | return new MeshObjectInfo |
| | 28 | | { |
| | 29 | | CopyCount = CopyCount, |
| | 30 | | MemoryUsage = MemoryUsage, |
| | 31 | | Name = Name, |
| | 32 | | Reference = Reference, |
| | 33 | | TotalMemoryUsage = TotalMemoryUsage, |
| | 34 | | Type = Type, |
| | 35 | | IsReadable = IsReadable, |
| | 36 | | SubMeshCount = SubMeshCount, |
| | 37 | | Triangles = Triangles |
| | 38 | | }; |
| 0 | 39 | | } |
| | 40 | |
|
| | 41 | | public override void Populate(Object targetObject, TransientReference reference = null) |
| 15 | 42 | | { |
| 15 | 43 | | base.Populate(targetObject, reference); |
| 15 | 44 | | Mesh meshAsset = (Mesh)targetObject; |
| | 45 | |
|
| | 46 | | // Useful mesh information |
| 15 | 47 | | VertexCount = meshAsset.vertexCount; |
| 15 | 48 | | SubMeshCount = meshAsset.subMeshCount; |
| 15 | 49 | | Triangles = meshAsset.triangles.Length; |
| 15 | 50 | | IsReadable = meshAsset.isReadable; |
| 15 | 51 | | } |
| | 52 | |
|
| | 53 | | public override string GetDetailedInformation(int maximumWidth) |
| 20 | 54 | | { |
| 20 | 55 | | return maximumWidth < 40 |
| | 56 | | ? $"{(IsReadable ? "RW" : "")} (V:{VertexCount.ToString()}, SM:{SubMeshCount.ToString()})" |
| | 57 | | : $"{(IsReadable ? "RW" : "")} (Verts:{VertexCount.ToString()}, SubMeshes:{SubMeshCount.ToString()})"; |
| 20 | 58 | | } |
| | 59 | | } |
| | 60 | | } |
| | 61 | | #endif // !UNITY_DOTSRUNTIME |