예제 #1
0
    public void SetRootViewController(UIViewController controller)
    {
        float x = 0, y = 0;

        if (rootViewController != null)
        {
            rootViewController.DestroyObjController();
        }
        rootViewController = controller;
        rootViewController.SetViewParent(canvasMain.gameObject);


        float         oft_top = Common.ScreenToCanvasHeigt(sizeCanvas, Device.offsetTop);
        float         oft_bottom = Common.ScreenToCanvasHeigt(sizeCanvas, Device.offsetBottom);
        float         oft_left = Common.ScreenToCanvasWidth(sizeCanvas, Device.offsetLeft);
        float         oft_right = Common.ScreenToCanvasWidth(sizeCanvas, Device.offsetRight);
        RectTransform rctran = rootViewController.objController.GetComponent <RectTransform>();

        y = oft_bottom - oft_top;
        x = oft_left - oft_right;
        //rctran.anchoredPosition = new Vector2(x, y);
        rctran.offsetMin = new Vector2(oft_left, oft_bottom);
        rctran.offsetMax = new Vector2(-oft_right, -oft_top);

        OnResize();
    }
 void DestroyController()
 {
     if (rootController != null)
     {
         rootController.DestroyObjController();
         rootController = null;
     }
 }