| | 1 | | using DCL; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityGLTF; |
| | 6 | |
|
| | 7 | | public class APK_GLTF_InteractiveTest : MonoBehaviour |
| | 8 | | { |
| | 9 | | ContentProvider_Dummy provider; |
| | 10 | | AssetPromiseKeeper_GLTF keeper; |
| | 11 | |
|
| 0 | 12 | | List<AssetPromise_GLTF> promiseList = new List<AssetPromise_GLTF>(); |
| | 13 | |
|
| | 14 | | void Start() |
| | 15 | | { |
| 0 | 16 | | GLTFSceneImporter.budgetPerFrameInMilliseconds = 4; |
| | 17 | |
|
| 0 | 18 | | provider = new ContentProvider_Dummy(); |
| 0 | 19 | | keeper = new AssetPromiseKeeper_GLTF(); |
| 0 | 20 | | } |
| | 21 | |
|
| | 22 | | void Generate(string url) |
| | 23 | | { |
| 0 | 24 | | AssetPromise_GLTF promise = new AssetPromise_GLTF(provider, url); |
| | 25 | |
|
| 0 | 26 | | Vector3 pos = Vector3.zero; |
| 0 | 27 | | pos.x = Random.Range(-10, 10); |
| 0 | 28 | | pos.z = Random.Range(-10, 10); |
| 0 | 29 | | promise.settings.initialLocalPosition = pos; |
| | 30 | |
|
| 0 | 31 | | keeper.Keep(promise); |
| 0 | 32 | | promiseList.Add(promise); |
| 0 | 33 | | } |
| | 34 | | static int counter = 0; |
| | 35 | | void Update() |
| | 36 | | { |
| 0 | 37 | | if (Input.GetKeyUp(KeyCode.Z)) |
| | 38 | | { |
| 0 | 39 | | counter++; |
| 0 | 40 | | counter %= 3; |
| 0 | 41 | | switch (counter) |
| | 42 | | { |
| | 43 | | case 0: |
| 0 | 44 | | string url = TestAssetsUtils.GetPath() + "/GLB/TrunkSeparatedTextures/Trunk.glb"; |
| 0 | 45 | | Generate(url); |
| 0 | 46 | | break; |
| | 47 | | case 1: |
| 0 | 48 | | string url2 = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb"; |
| 0 | 49 | | Generate(url2); |
| 0 | 50 | | break; |
| | 51 | | case 2: |
| 0 | 52 | | string url3 = TestAssetsUtils.GetPath() + "/GLB/DamagedHelmet/DamagedHelmet.glb"; |
| 0 | 53 | | Generate(url3); |
| 0 | 54 | | break; |
| | 55 | | } |
| | 56 | |
|
| | 57 | | } |
| 0 | 58 | | else if (Input.GetKeyUp(KeyCode.X)) |
| | 59 | | { |
| 0 | 60 | | if (promiseList.Count > 0) |
| | 61 | | { |
| 0 | 62 | | var promiseToRemove = promiseList[Random.Range(0, promiseList.Count)]; |
| 0 | 63 | | keeper.Forget(promiseToRemove); |
| 0 | 64 | | promiseList.Remove(promiseToRemove); |
| | 65 | | } |
| | 66 | | } |
| | 67 | |
|
| 0 | 68 | | } |
| | 69 | | } |