| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace DCL |
| | 5 | | { |
| | 6 | | public class AssetPromise_PrimitiveMesh : AssetPromise<Asset_PrimitiveMesh> |
| | 7 | | { |
| | 8 | | private readonly AssetPromise_PrimitiveMesh_Model model; |
| | 9 | |
|
| 0 | 10 | | public AssetPromise_PrimitiveMesh(AssetPromise_PrimitiveMesh_Model model) |
| | 11 | | { |
| 0 | 12 | | this.model = model; |
| 0 | 13 | | } |
| | 14 | |
|
| 32 | 15 | | protected override void OnAfterLoadOrReuse() { } |
| | 16 | |
|
| 32 | 17 | | protected override void OnBeforeLoadOrReuse() { } |
| | 18 | |
|
| 0 | 19 | | protected override void OnCancelLoading() { } |
| | 20 | |
|
| | 21 | | protected override void OnLoad(Action OnSuccess, Action<Exception> OnFail) |
| | 22 | | { |
| | 23 | | try |
| | 24 | | { |
| 25 | 25 | | Mesh currentMesh = PrimitiveMeshFactory.CreateMesh(model); |
| 25 | 26 | | asset.mesh = currentMesh; |
| 25 | 27 | | OnSuccess?.Invoke(); |
| 25 | 28 | | } |
| 0 | 29 | | catch (Exception e) |
| | 30 | | { |
| 0 | 31 | | OnFail?.Invoke(e); |
| 0 | 32 | | } |
| 25 | 33 | | } |
| | 34 | |
|
| | 35 | | protected override bool AddToLibrary() |
| | 36 | | { |
| 25 | 37 | | if (!library.Add(asset)) |
| | 38 | | { |
| 0 | 39 | | return false; |
| | 40 | | } |
| | 41 | |
|
| 25 | 42 | | asset = library.Get(asset.id); |
| 25 | 43 | | return true; |
| | 44 | | } |
| | 45 | |
|
| | 46 | | public override object GetId() |
| | 47 | | { |
| 176 | 48 | | return model; |
| | 49 | | } |
| | 50 | | } |
| | 51 | | } |