protected virtual void Start()
 {
     if (view == null)
     {
         var panel = new ViewBase_Diffuse();
         panel.Binding(gameObject);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 从对象池或创建代码
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public IUIPanel GetPanelFromPool(GameObject target)
        {
            var             panelName = target.name;
            IUIPanel        panel     = null;
            List <IUIPanel> panels    = null;

            if (!panelPool.TryGetValue(panelName, out panels))
            {
                panelPool[panelName] = panels = new List <IUIPanel>();
            }

            if (panels.Count > 0)
            {
                panel = panels[0];
                panels.RemoveAt(0);
            }

            if (panel == null)
            {
                var panelRef = target.GetComponent <IUIPanelReference>();

                if (panelRef != null)
                {
                    var type = panelRef.CetPanelScriptType();
                    if (type != null)
                    {
                        panel = System.Activator.CreateInstance(type) as IUIPanel;
                    }
                }

                if (panel == null)
                {
                    panel = new ViewBase_Diffuse();
                }
            }
            return(panel);
        }