コード例 #1
0
    public void ShowSSImage(int stageIndex = 1)
    {
        content = Instantiate(contentPre, GameObject.Find("Viewport").transform);
        foreach (string item in snap.pathList)
        {
            string[] path = item.Split(',');
            string[] pos  = path[0].Split('_', '.');

            if (pos[0] == "Assets/Resources/Album/Stage" + stageIndex + "/")
            {
                byte[] image = File.ReadAllBytes(path[0]);

                Texture2D tex = new Texture2D(0, 0);
                tex.LoadImage(image);

                RawImage target = Instantiate(targetImage, content).GetComponent <RawImage>();
                target.texture = tex;

                PhotoSpot ps = target.GetComponent <PhotoSpot>();
                ps.spot     = (SPOT)Enum.Parse(typeof(SPOT), path[1]);
                ps.albumPos = new Vector2(float.Parse(path[2]), float.Parse(path[3]));
                ps.stage    = stageIndex;

                target.name = item;

                target.GetComponent <RectTransform>().localPosition = new Vector2(int.Parse(pos[1]) * 10 + 1200, int.Parse(pos[2]) * 10 - 750);
            }
        }
    }
コード例 #2
0
    public void SelectPic()
    {
        Ray ray = new Ray(transform.position, transform.forward);

        RaycastHit2D hit = Physics2D.Raycast((Vector2)ray.origin, (Vector2)ray.direction);

        if (hit.collider.GetComponent <PhotoSpot>().spot == SPOT.GOOD)
        {
            PhotoSpot ps  = hit.collider.GetComponent <PhotoSpot>();
            Vector2   pos = ps.albumPos;

            GameManager.instance.stage = ps.stage;

            player.position = pos;

            StartCoroutine(GameManager.instance.ChangeStage(ps.stage));
            Debug.Log(pos.x + ":" + pos.y);
        }
    }