Beispiel #1
0
    private UILayer ShowLayer(UILayer layer)
    {
#if USE_XLUA
        return(InvokeXLua("ShowLayer", new object[] { layer })[0] as UILayer);
#else
        if (layer == null)
        {
            return(null);
        }

        UILayer lastLayer = null;

        List <UILayer> uiLayerTemps = layers[layer.position];

        int layerCount = uiLayerTemps.Count;

        // disable layer
        if (layerCount > 0)
        {
            lastLayer = uiLayerTemps[layerCount - 1];
            lastLayer.DisableLayer();
        }

        if (layer.position == UILayer.Position.Middle)
        {
            layerMiniMask.SetActive(true);
        }

        layer.SetLayerIndex(layerCount);
        uiLayerTemps.Add(layer);
        layer.EnableLayer();

        // animation
        switch (layer.layerAnimType)
        {
        case UILayer.AnimType.Popup:
            layer.PlayAnimation(UILayer.AnimKey.OpenPopup);
            break;

        case UILayer.AnimType.None:
            if (layer.hideBehindLayers)
            {
                if (lastLayer != null)
                {
                    lastLayer.gameObject.SetActive(false);
                }
            }
            break;
        }

        return(layer);
#endif
    }
Beispiel #2
0
    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
    }