public void RemoveLayerGame() { #if USE_XLUA InvokeXLua("RemoveLayerGame"); #else foreach (var item in layerCaches) { var layerTemps = item.Value; if (layerTemps.Count > 0) { for (int i = layerTemps.Count - 1; i >= 0; i--) { UILayer layer = layerTemps[i]; if (layer.isGameLayer) { layerTemps.Remove(layer); layer.DisableLayer(); layer.BeforeHideLayer(); layer.HideLayer(); layer.DestroyLayer(); Destroy(layer.gameObject); } } } } UnloadAllAssets(); #endif }
void Start() { if (readyLayers != null && readyLayers.Count > 0) { foreach (var key in readyLayers) { UILayer layer = CreateLayer(key); layer.BeforeHideLayer(); layer.HideLayer(); layer.gameObject.SetActive(false); CacheLayer(layer); } } if (firstLayer != UILayerKey.None) { UILayer mLayer = ShowLayer(firstLayer); mLayer.FirstLoadLayer(); } }
private void PrivateHideLayer(UILayer layer) { #if USE_XLUA InvokeXLua("PrivateHideLayer", layer); #else layer.DisableLayer(); layer.BeforeHideLayer(); layer.HideLayer(); if (layer.allowDestroy) { layer.DestroyLayer(); Destroy(layer.gameObject); } else { layer.ResetPosition(); CacheLayer(layer); } #endif }
public void HideLayer(UILayer layer) { #if USE_XLUA InvokeXLua("HideLayer", layer); #else if (layer == null) { return; } List <UILayer> uiLayerTemps = layers[layer.position]; if (!uiLayerTemps.Contains(layer)) { return; } // remove uiLayerTemps.Remove(layer); UILayer lastLayer = null; if (layer.layerIndex > 0 && uiLayerTemps.Count > layer.layerIndex - 1) { try { lastLayer = uiLayerTemps[layer.layerIndex - 1]; lastLayer.gameObject.SetActive(true); lastLayer.ReloadLayer(); } catch (Exception e) { VKDebug.LogWarning("DONOT HAVE LAYER " + (layer.layerIndex - 1) + " - " + e.Message); } } if (layer.layerIndex == uiLayerTemps.Count) { if (lastLayer != null) { lastLayer.EnableLayer(); } } else { for (int i = layer.layerIndex; i < uiLayerTemps.Count; i++) { uiLayerTemps[i].SetLayerIndex(i); } } // call hide layer.BeforeHideLayer(); //// if last game in middle close => clear all layer game cache and layer cache > 5 //if (layer.position == UILayer.Position.Middle && uiLayerTemps.Count <= 0) //{ // layerMiniMask.SetActive(false); // StartCoroutine(WaitRemoveLayerGame(layer)); //} switch (layer.layerAnimType) { case UILayer.AnimType.None: layer.HideLayer(); if (layer.allowDestroy) { layer.DestroyLayer(); Destroy(layer.gameObject); UnloadAllAssets(); } else { CacheLayer(layer); } break; case UILayer.AnimType.Popup: layer.PlayAnimation(UILayer.AnimKey.ClosePopup); break; } #endif }