예제 #1
0
        private UILayerBase GetOrCreateLayer(UILayerDBEntry layerDBEntry)
        {
            if (!layerDBEntry.IsAssigned())
            {
                return(_defaultLayer);
            }
            if (_layers.ContainsKey(layerDBEntry))
            {
                return(_layers[layerDBEntry]);
            }
            var existedButNotCached = GetComponentsInChildren <UILayerBase>().First(l => l.layerDBEntry == layerDBEntry);

            if (existedButNotCached != null)
            {
                _layers.AddOrSet(layerDBEntry, existedButNotCached);
                return(existedButNotCached);
            }
            return(CreateLayer(layerDBEntry));
        }
예제 #2
0
        private UILayerBase CreateLayer(UILayerDBEntry layerDBEntry)
        {
            var layerPrefab = layerDBEntry.LoadPrefab <UILayerBase>();

            if (layerPrefab == null)
            {
                layerPrefab = defaultLayerSrc;
            }
            var layer = layerPrefab.Clone(transform);

            layer.Init(layerDBEntry);
            _layers.Add(layerDBEntry, layer);
            transform.SetChildrenSiblingIndex(c => {
                var canvas = c.GetComponent <Canvas>();
                if (canvas == null)
                {
                    return(1000);
                }

                return(c.GetComponent <Canvas>().sortingOrder);
            });
            return(layer);
        }
 public void Init(UILayerDBEntry layerDBEntry)
 {
     name = layerDBEntry.name;
     canvas.sortingOrder = layerDBEntry.sortOrder;
 }