| | 1 | | using DCL; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using DCL.Helpers; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | public class APK_AB_InteractiveTest : MonoBehaviour |
| | 7 | | { |
| | 8 | | AssetPromiseKeeper_AB_GameObject keeper; |
| 0 | 9 | | List<AssetPromise_AB_GameObject> promiseList = new List<AssetPromise_AB_GameObject>(); |
| | 10 | |
|
| 0 | 11 | | public string baseUrl = ""; |
| 0 | 12 | | public string fileToLoad = "QmZFSGh3KYXC4hnjjUvdnqE1owraaMcFXny8oL6ctHR47L"; |
| | 13 | |
|
| 0 | 14 | | private Vector3 posOffset = Vector3.zero; |
| | 15 | |
|
| | 16 | | void Start() |
| | 17 | | { |
| 0 | 18 | | keeper = new AssetPromiseKeeper_AB_GameObject(); |
| 0 | 19 | | } |
| | 20 | |
|
| | 21 | | void Generate(string url, string hash) |
| | 22 | | { |
| 0 | 23 | | AssetPromise_AB_GameObject promise = new AssetPromise_AB_GameObject(url, hash); |
| | 24 | |
|
| 0 | 25 | | Vector3 pos = posOffset; |
| 0 | 26 | | promise.settings.initialLocalPosition = pos; |
| | 27 | |
|
| 0 | 28 | | posOffset += Vector3.right * 10; |
| | 29 | |
|
| 0 | 30 | | keeper.Keep(promise); |
| 0 | 31 | | promiseList.Add(promise); |
| 0 | 32 | | } |
| | 33 | |
|
| | 34 | | void Update() |
| | 35 | | { |
| 0 | 36 | | if (Input.GetKeyUp(KeyCode.Z)) |
| | 37 | | { |
| 0 | 38 | | if (string.IsNullOrEmpty(baseUrl)) |
| 0 | 39 | | baseUrl = new System.Uri(Application.dataPath + "/../AssetBundles").AbsoluteUri + "/"; |
| | 40 | |
|
| 0 | 41 | | Generate(baseUrl, fileToLoad); |
| 0 | 42 | | } |
| 0 | 43 | | else if (Input.GetKeyUp(KeyCode.X)) |
| | 44 | | { |
| 0 | 45 | | if (promiseList.Count > 0) |
| | 46 | | { |
| 0 | 47 | | var promiseToRemove = promiseList[Random.Range(0, promiseList.Count)]; |
| 0 | 48 | | keeper.Forget(promiseToRemove); |
| 0 | 49 | | promiseList.Remove(promiseToRemove); |
| | 50 | | } |
| | 51 | | } |
| 0 | 52 | | } |
| | 53 | | } |