示例#1
0
    public void ToggleCanvas(CanvasType type)
    {
        Debug.Log("Toggle called on " + type.ToString());
        CanvasController toggled = canvasControllerList.Find(canvas => canvas.canvasType == type);

        if (toggled != null)
        {
            if (!toggled.isShown)
            {
                Debug.Log("Was hidden");
                if (type == CanvasType.HUDCanvas)
                {
                    Cursor.visible = false;
                }
                else
                {
                    Cursor.visible = true;
                }
                toggled.gameObject.SetActive(true);
                toggled.isShown = true;

                if (type != CanvasType.HUDCanvas)
                {
                    if (type != CanvasType.LoadingCanvas)
                    {
                        Time.timeScale = 0f;
                        Debug.Log("Time scale 0 and CursorConfined");
                        Cursor.lockState = CursorLockMode.Confined;
                    }
                    gameManager.gameIsPaused = true;
                }
            }
            else
            {
                Debug.Log("Was shown");
                if (type == CanvasType.HUDCanvas)
                {
                    Cursor.visible = true;
                }
                else
                {
                    Cursor.visible = false;
                }
                toggled.gameObject.SetActive(false);
                toggled.isShown = false;

                if (type != CanvasType.HUDCanvas)
                {
                    if (type != CanvasType.LoadingCanvas)
                    {
                        Time.timeScale   = 1f;
                        Cursor.lockState = CursorLockMode.Locked;
                        Debug.Log("Time scale 1 and Cursor Locked");
                    }
                    gameManager.gameIsPaused = false;
                }
            }
        }
    }
示例#2
0
    public void LoadCanvas(CanvasType type)
    {
        GameObject root_Canvas = GameObject.Find("Canvas");
        GameObject canvas      = Instantiate(Resources.Load <GameObject>("UI/" + type.ToString()));

        canvas.transform.parent        = root_Canvas.transform;
        canvas.transform.localPosition = Vector3.zero;
    }