| | 1 | | using System.Collections.Generic; |
| | 2 | | using DCL.Configuration; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL |
| | 6 | | { |
| | 7 | | public class Asset_AB_GameObject : Asset_WithPoolableContainer |
| | 8 | | { |
| | 9 | | internal AssetPromise_AB ownerPromise; |
| | 10 | |
|
| 435 | 11 | | public override GameObject container { get; set; } |
| 17 | 12 | | public Dictionary<Mesh, int> meshToTriangleCount = new Dictionary<Mesh, int>(); |
| 17 | 13 | | public HashSet<Renderer> renderers = new HashSet<Renderer>(); |
| 17 | 14 | | public HashSet<Mesh> meshes = new HashSet<Mesh>(); |
| 17 | 15 | | public HashSet<Material> materials = new HashSet<Material>(); |
| 17 | 16 | | public HashSet<Texture> textures = new HashSet<Texture>(); |
| | 17 | | public int totalTriangleCount = 0; |
| | 18 | |
|
| 17 | 19 | | public Asset_AB_GameObject() |
| | 20 | | { |
| 17 | 21 | | container = new GameObject("AB Container"); |
| | 22 | | // Hide gameobject until it's been correctly processed, otherwise it flashes at 0,0,0 |
| 17 | 23 | | container.transform.position = EnvironmentSettings.MORDOR; |
| 17 | 24 | | } |
| | 25 | |
|
| | 26 | | public override object Clone() |
| | 27 | | { |
| 36 | 28 | | Asset_AB_GameObject result = this.MemberwiseClone() as Asset_AB_GameObject; |
| 36 | 29 | | result.meshes = new HashSet<Mesh>(meshes); |
| 36 | 30 | | result.meshToTriangleCount = new Dictionary<Mesh, int>(meshToTriangleCount); |
| 36 | 31 | | result.renderers = new HashSet<Renderer>(renderers); |
| 36 | 32 | | result.materials = new HashSet<Material>(materials); |
| 36 | 33 | | result.textures = new HashSet<Texture>(textures); |
| 36 | 34 | | return result; |
| | 35 | | } |
| | 36 | |
|
| | 37 | |
|
| | 38 | | public override void Cleanup() |
| | 39 | | { |
| 18 | 40 | | AssetPromiseKeeper_AB.i.Forget(ownerPromise); |
| 18 | 41 | | Object.Destroy(container); |
| 18 | 42 | | } |
| | 43 | |
|
| | 44 | | public void Show(System.Action OnFinish) |
| | 45 | | { |
| 25 | 46 | | OnFinish?.Invoke(); |
| 25 | 47 | | } |
| | 48 | |
|
| | 49 | | public void Hide() |
| | 50 | | { |
| 1 | 51 | | container.transform.parent = null; |
| 1 | 52 | | container.transform.position = EnvironmentSettings.MORDOR; |
| 1 | 53 | | } |
| | 54 | | } |
| | 55 | | } |