예제 #1
0
    // Use this for initialization
    void Start()
    {
        Instance = this;

        subCamera = gameObject.GetComponent <Camera>();

        // 横20pixelは何パーセントか
        float marginHorz = pxMarginHorz / Screen.width;

        // 縦40pixelは何パーセントか
        float marginVert = pxMarginVert / Screen.height;

        // 縦のパーセンテージ
        float height = rtVert;
        // 縦40%は何ピクセルか
        float pxVert = Screen.height * height;
        // 縦40%のピクセル数は横何パーセントか
        //float width = px40vert / Screen.width;
        // 横215ピクセルは横何パーセントか
        float width = pxHorz / Screen.width;

        subCamera.rect = new Rect(1f - (marginHorz + width), 1f - (marginVert + height), width, height);

        float x = Screen.width - (pxMarginHorz + pxHorz);
        float y = Screen.height - (pxMarginVert + pxVert);

        rect = new Rect(x, y, pxHorz, pxVert);
    }
예제 #2
0
 void updateDistance(float scroll)
 {
     if (SubCameraController.Contains(Input.mousePosition))
     {
         SubCameraController.Zoom(scroll);
     }
     else
     {
         scroll   = distance - scroll * scrollSensitivity;
         distance = Mathf.Clamp(scroll, minDistance, maxDistance);
     }
 }