コード例 #1
0
    IEnumerator Render(GIFImage image, GameObject target)
    {
        var texture         = new Texture2D(image.screen.width, image.screen.height);
        var renderingBlocks = image.data.Where(d => d is IGIFRenderingBlock).Cast <IGIFRenderingBlock>().ToList();
        var idx             = 0;

        while (true)
        {
            var colorArr = new Color32[texture.width * texture.height];
            if (idx >= renderingBlocks.Count)
            {
                idx = 0;
            }
            var data = renderingBlocks[idx];
            data.DrawTo(colorArr, texture.width, texture.height);
            texture.SetPixels32(colorArr);
            texture.Apply(true);

            var scale = (Screen.height / 2.0) / Camera.main.orthographicSize;
            target.transform.localScale.Set((float)(texture.width / scale), (float)(texture.height / scale), target.transform.localScale.z);
            target.GetComponent <Renderer>().material.mainTexture = texture;
            idx++;
            yield return(new WaitForSeconds(0.013f));
        }
    }
コード例 #2
0
        public static ISaveImage GuardarFormatoImagen(string option)
        {
            ISaveImage saveImage = null;

            switch (option)
            {
            case "1":
                saveImage = new GIFImage();
                break;

            case "2":
                saveImage = new JPGImage();
                break;

            case "3":
                saveImage = new PNGImage();
                break;

            default:
                break;
            }

            return(saveImage);
        }