Exemplo n.º 1
0
        public virtual void SetViewAsset(GameObject gameObject)
        {
            gameObject.name = config.viewName;
            this.transform  = gameObject.transform;
            ViewModelBinding binding = gameObject.GetComponent <ViewModelBinding>();

            if (binding != null)
            {
                binding.view = this;
                if (model != null)
                {
                    binding.SetModel(model);
                }
            }
            MonoBehaviourEvent objectEvent = gameObject.AddComponent <MonoBehaviourEvent>();

            objectEvent.onStartEvent   += OnCreated;
            objectEvent.onEnableEvent  += OnShow;
            objectEvent.onDisableEvent += OnHide;
            objectEvent.onDestroyEvent += OnDestroyed;
            isLoadingAsset              = false;
            if (OnLoadAsset != null)
            {
                OnLoadAsset();
            }
            if (delayShow)
            {
                Show();
            }
            delayShow = false;
        }
Exemplo n.º 2
0
        protected virtual Transform CreateChild(IModel model)
        {
            ViewModelBinding binding = CreateChildInCache(model);

            if (binding != null)
            {
                binding.transform.SetAsLastSibling();
                binding.gameObject.SetActive(true);
                binding.SetModel(model);
                usedChildList.Add(binding);
            }
            return(binding.transform);
        }
Exemplo n.º 3
0
        protected Transform CreateChild(IModel model, int index)
        {
            Transform child;

            if (index < componentList.childCount)
            {
                child = componentList.GetChild(index);
            }
            else
            {
                child = Object.Instantiate(componentElement.transform, Vector3.zero, Quaternion.identity, componentList);
            }
            child.gameObject.SetActive(true);
            ViewModelBinding binding = child.GetComponent <ViewModelBinding>();

            binding.SetModel(model);
            return(child);
        }