| | 1 | | using DCL.Components; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | public class SmartItemListView : MonoBehaviour |
| | 7 | | { |
| | 8 | | [SerializeField] private SmartItemParameterFactory factory; |
| | 9 | |
|
| 47 | 10 | | List<DCLBuilderInWorldEntity> entitiesList = new List<DCLBuilderInWorldEntity>(); |
| | 11 | |
|
| 47 | 12 | | List<GameObject> childrenList = new List<GameObject>(); |
| | 13 | |
|
| | 14 | | public void SetSmartItemParameters(SmartItemParameter[] parameters, Dictionary<object, object> smartItemValues) |
| | 15 | | { |
| 0 | 16 | | for (int i = 0; i < childrenList.Count; i++) |
| | 17 | | { |
| 0 | 18 | | Destroy(childrenList[i]); |
| | 19 | | } |
| | 20 | |
|
| 0 | 21 | | gameObject.SetActive(true); |
| | 22 | |
|
| 0 | 23 | | foreach (SmartItemParameter parameter in parameters) |
| | 24 | | { |
| 0 | 25 | | SmartItemUIParameterAdapter prefabToInstantiate = factory.GetPrefab(parameter.GetParameterType()); |
| 0 | 26 | | InstantiateParameter(parameter, smartItemValues, prefabToInstantiate); |
| | 27 | | } |
| 0 | 28 | | } |
| | 29 | |
|
| 0 | 30 | | public void SetEntityList(List<DCLBuilderInWorldEntity> entitiesList) { this.entitiesList = BuilderInWorldUtils.Remo |
| | 31 | |
|
| | 32 | | void InstantiateParameter(SmartItemParameter parameter, Dictionary<object, object> smartItemValues, SmartItemUIParam |
| | 33 | | { |
| 0 | 34 | | SmartItemUIParameterAdapter parameterAdapter = Instantiate(parameterAdapterPrefab.gameObject, transform).GetComp |
| | 35 | |
|
| 0 | 36 | | IEntityListHandler entityListHanlder = parameterAdapter.GetComponent<IEntityListHandler>(); |
| 0 | 37 | | if (entityListHanlder != null) |
| 0 | 38 | | entityListHanlder.SetEntityList(entitiesList); |
| | 39 | |
|
| 0 | 40 | | parameterAdapter.SetParameter(parameter, smartItemValues); |
| 0 | 41 | | childrenList.Add(parameterAdapter.gameObject); |
| 0 | 42 | | } |
| | 43 | | } |