| | 1 | | using System.Collections.Generic; |
| | 2 | | using DCL.Configuration; |
| | 3 | | using MainScripts.DCL.Analytics.PerformanceAnalytics; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | namespace DCL |
| | 7 | | { |
| | 8 | | public class Asset_AB_GameObject : Asset_WithPoolableContainer |
| | 9 | | { |
| | 10 | | private const string CONTAINER_GO_NAME = "AB Container"; |
| | 11 | |
|
| | 12 | | internal AssetPromise_AB ownerPromise; |
| | 13 | |
|
| 424 | 14 | | public override GameObject container { get; set; } |
| 20 | 15 | | public Dictionary<Mesh, int> meshToTriangleCount = new Dictionary<Mesh, int>(); |
| 20 | 16 | | public HashSet<Renderer> renderers = new HashSet<Renderer>(); |
| 20 | 17 | | public HashSet<Mesh> meshes = new HashSet<Mesh>(); |
| 20 | 18 | | public HashSet<Material> materials = new HashSet<Material>(); |
| 20 | 19 | | public HashSet<Texture> textures = new HashSet<Texture>(); |
| 20 | 20 | | public HashSet<AnimationClip> animationClips = new HashSet<AnimationClip>(); |
| | 21 | | public int totalTriangleCount = 0; |
| | 22 | | public long animationClipSize = 0; |
| | 23 | | public long meshDataSize = 0; |
| | 24 | |
|
| 20 | 25 | | public Asset_AB_GameObject() |
| | 26 | | { |
| 20 | 27 | | container = new GameObject(CONTAINER_GO_NAME); |
| | 28 | | // Hide gameobject until it's been correctly processed, otherwise it flashes at 0,0,0 |
| 20 | 29 | | container.transform.position = EnvironmentSettings.MORDOR; |
| 20 | 30 | | } |
| | 31 | |
|
| | 32 | | public override object Clone() |
| | 33 | | { |
| 37 | 34 | | Asset_AB_GameObject result = this.MemberwiseClone() as Asset_AB_GameObject; |
| 37 | 35 | | result.meshes = new HashSet<Mesh>(meshes); |
| 37 | 36 | | result.meshToTriangleCount = new Dictionary<Mesh, int>(meshToTriangleCount); |
| 37 | 37 | | result.renderers = new HashSet<Renderer>(renderers); |
| 37 | 38 | | result.materials = new HashSet<Material>(materials); |
| 37 | 39 | | result.textures = new HashSet<Texture>(textures); |
| 37 | 40 | | result.animationClips = new HashSet<AnimationClip>(animationClips); |
| 37 | 41 | | return result; |
| | 42 | | } |
| | 43 | |
|
| | 44 | | public override void Cleanup() |
| | 45 | | { |
| 21 | 46 | | AssetPromiseKeeper_AB.i.Forget(ownerPromise); |
| 21 | 47 | | Object.Destroy(container); |
| 21 | 48 | | } |
| | 49 | |
|
| | 50 | | public void Show(System.Action OnFinish) |
| | 51 | | { |
| 25 | 52 | | OnFinish?.Invoke(); |
| 25 | 53 | | } |
| | 54 | |
|
| | 55 | | public void Hide() |
| | 56 | | { |
| 1 | 57 | | container.transform.parent = null; |
| 1 | 58 | | container.transform.position = EnvironmentSettings.MORDOR; |
| 1 | 59 | | } |
| | 60 | | public void SetTextures(HashSet<Texture> texturesHashSet) |
| | 61 | | { |
| 12 | 62 | | textures = texturesHashSet; |
| | 63 | |
|
| 48 | 64 | | for (int i = 0; i < textures.Count; i++) |
| | 65 | | { |
| 12 | 66 | | PerformanceAnalytics.ABTextureTracker.Track(); |
| | 67 | | } |
| 12 | 68 | | } |
| | 69 | | } |
| | 70 | | } |