Beispiel #1
0
        public void Apply(IEntity entity)
        {
            var uiComponent = new UIComponet {
                UIName = uiName, IsDynamic = true, UIType = type
            };

            entity.AddComponent(uiComponent);
            entity.AddComponent <ViewComponent>();
        }
Beispiel #2
0
        public override GameObject ResolveView(IEntity entity)
        {
            UIComponet uiComponet = entity.GetComponent <UIComponet>();
            //GameObject prefab = Resources.Load(UIManager.Resource + uiComponet.UIName) as GameObject;
            Scene      scene     = SceneManager.GetActiveScene();
            GameObject uiRoot    = scene.GetRootGameObjects().Single(o => o.name == UIManager.UIRoot);
            Transform  container = uiRoot.transform;

            if (uiComponet.Container != "")
            {
                container = uiRoot.transform.Find(uiComponet.Container);
            }
            GameObject ui = instantiator.InstantiatePrefabResource(UIManager.Resource + uiComponet.UIName);

            ui.transform.SetParent(container, false);
            return(ui);
        }