| | 1 | | using UnityEngine; |
| | 2 | | using UnityGLTF; |
| | 3 | |
|
| | 4 | | namespace DCL |
| | 5 | | { |
| | 6 | | public class PoolInstantiator_GLTF : IPooledObjectInstantiator |
| | 7 | | { |
| | 8 | | public bool IsValid(GameObject original) |
| | 9 | | { |
| 1 | 10 | | InstantiatedGLTFObject results = original.GetComponentInChildren<InstantiatedGLTFObject>(true); |
| 1 | 11 | | return results != null; |
| | 12 | | } |
| | 13 | |
|
| | 14 | | public GameObject Instantiate(GameObject original) |
| | 15 | | { |
| 116 | 16 | | if (original == null) |
| | 17 | | { |
| 0 | 18 | | Debug.LogError("PoolInstantiator_GLTF: Invalid original gameObject!"); |
| 0 | 19 | | return new GameObject("_PoolInstantiator_Error"); |
| | 20 | | } |
| | 21 | |
|
| 116 | 22 | | InstantiatedGLTFObject gltfInstance = original.GetComponentInChildren<InstantiatedGLTFObject>(true); |
| | 23 | |
|
| 116 | 24 | | if (gltfInstance == null) |
| | 25 | | { |
| 0 | 26 | | Debug.LogWarning("PoolInstantiator_GLTF: Invalid GLTF! Couldn't duplicate correctly."); |
| 0 | 27 | | GameObject result = Object.Instantiate(original); |
| 0 | 28 | | result.name += "_Error"; |
| 0 | 29 | | return result; |
| | 30 | | } |
| | 31 | |
|
| | 32 | | InstantiatedGLTFObject gltfDuplicate = null; |
| | 33 | |
|
| 116 | 34 | | gltfDuplicate = gltfInstance.Duplicate(); |
| | 35 | |
|
| 116 | 36 | | return gltfDuplicate.gameObject; |
| | 37 | | } |
| | 38 | | } |
| | 39 | | } |