| | 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 | |
|
| 373 | 11 | | public override GameObject container { get; set; } |
| 16 | 12 | | public List<Mesh> meshes = new List<Mesh>(); |
| 16 | 13 | | public Dictionary<Mesh, int> meshToTriangleCount = new Dictionary<Mesh, int>(); |
| 16 | 14 | | public List<Renderer> renderers = new List<Renderer>(); |
| | 15 | | public int totalTriangleCount = 0; |
| | 16 | |
|
| 16 | 17 | | public Asset_AB_GameObject() |
| | 18 | | { |
| 16 | 19 | | container = new GameObject("AB Container"); |
| | 20 | | // Hide gameobject until it's been correctly processed, otherwise it flashes at 0,0,0 |
| 16 | 21 | | container.transform.position = EnvironmentSettings.MORDOR; |
| 16 | 22 | | } |
| | 23 | |
|
| | 24 | | public override object Clone() |
| | 25 | | { |
| 34 | 26 | | Asset_AB_GameObject result = this.MemberwiseClone() as Asset_AB_GameObject; |
| 34 | 27 | | result.meshes = new List<Mesh>(meshes); |
| 34 | 28 | | result.meshToTriangleCount = new Dictionary<Mesh, int>(meshToTriangleCount); |
| 34 | 29 | | result.renderers = new List<Renderer>(renderers); |
| 34 | 30 | | return result; |
| | 31 | | } |
| | 32 | |
|
| | 33 | |
|
| | 34 | | public override void Cleanup() |
| | 35 | | { |
| 17 | 36 | | AssetPromiseKeeper_AB.i.Forget(ownerPromise); |
| 17 | 37 | | Object.Destroy(container); |
| 17 | 38 | | } |
| | 39 | |
|
| | 40 | | public void Show(System.Action OnFinish) |
| | 41 | | { |
| 24 | 42 | | OnFinish?.Invoke(); |
| 24 | 43 | | } |
| | 44 | |
|
| | 45 | | public void Hide() |
| | 46 | | { |
| 1 | 47 | | container.transform.parent = null; |
| 1 | 48 | | container.transform.position = EnvironmentSettings.MORDOR; |
| 1 | 49 | | } |
| | 50 | | } |
| | 51 | | } |