public void Save()
    {
        var piList = new List <CorrectableQuad.PointInfomation>();

        for (var i = 0; i < Points.Length; i++)
        {
            var p  = Points[i];
            var uv = new Vector2(
                EMath.Map(p.x, -aspect.x / 2f, aspect.x / 2f, 0, 1),
                EMath.Map(p.y, -aspect.y / 2f, aspect.y / 2f, 0, 1)
                );
            var pi = new CorrectableQuad.PointInfomation
            {
                position = p,
                uv       = uv
            };
            piList.Add(pi);
            print(i + " : " + uv);
        }

        var setting = new QuadCorrectionSetting();

        setting.LeftTop     = new CorrectableQuad.JPointInfomation(piList[0]);
        setting.RightTop    = new CorrectableQuad.JPointInfomation(piList[1]);
        setting.RightBottom = new CorrectableQuad.JPointInfomation(piList[2]);
        setting.LeftBottom  = new CorrectableQuad.JPointInfomation(piList[3]);
        CorrectEvent?.Invoke(setting);
        IOHandler.SaveJson(IOHandler.IntoStreamingAssets(settingFileName), setting);
    }
예제 #2
0
 //Unityの座標系に合わせて正規化された座標(-1~+1)
 public static Vector2 GetUnityCoordinateSystemNormalizedPosition(Vector2 position, Vector2 textureSize)
 {
     return(new Vector2(EMath.Map(position.x, 0f, textureSize.x, -1f, 1f),
                        EMath.Map(position.y, 0f, textureSize.y, 1f, -1f)));
 }
예제 #3
0
  //画面上の位置を取得
  //一気にUnity上の画面の位置に変換する
 public static Vector2 GetUnityCoordinateSystemPosition(Vector2 position, Vector2 area1, Vector2 area2)
 {
     return(new Vector2(EMath.Map(position.x, 0f, area1.x, -area2.x / 2f, area2.x / 2f),
                        EMath.Map(position.y, 0f, area1.y, area2.y / 2f, -area2.y / 2f)));
 }