public void OnOrientationChange(object sender, OnOrientationChangeEventArg args)
    {
        ScreenOrientation orientation = args.Orientation;

        if (orientation == ScreenOrientation.Landscape)
        {
            if (verticalPanel.childCount > 0)
            {
                horizontalPanel.gameObject.SetActive(true);
                verticalPanel.gameObject.SetActive(false);
                int numChild = verticalPanel.childCount;
                for (int i = 0; i < numChild; i++)
                {
                    verticalPanel.GetChild(0).SetParent(horizontalPanel);
                }
            }
        }
        else
        {
            if (horizontalPanel.childCount > 0)
            {
                horizontalPanel.gameObject.SetActive(false);
                verticalPanel.gameObject.SetActive(true);
                int numChild = horizontalPanel.childCount;
                for (int i = 0; i < numChild; i++)
                {
                    horizontalPanel.GetChild(0).SetParent(verticalPanel);
                }
            }
        }
    }
Exemplo n.º 2
0
    private void OnOrientationChange(object sender, OnOrientationChangeEventArg args)
    {
        ScreenOrientation orientation = args.Orientation;

        if (orientation == ScreenOrientation.Portrait)
        {
            this.GetComponentInParent <Camera>().orthographicSize = ((float)Screen.height / (float)Screen.width) * 5.0f;
        }
        else
        {
            this.GetComponentInParent <Camera>().orthographicSize = 5.0f;
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        ScreenOrientation newOrientation;

        if (Screen.width < Screen.height)
        {
            newOrientation = ScreenOrientation.Portrait;
        }
        else
        {
            newOrientation = ScreenOrientation.Landscape;
        }

        if (orientation != newOrientation)
        {
            orientation = newOrientation;
            OnOrientationChangeEventArg args = new OnOrientationChangeEventArg(orientation);

            if (OnOrientationChange != null)
            {
                OnOrientationChange(this, args);
            }
        }
    }