using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UnityHelper : MonoBehaviour {
public static Vector2[] v3Tv2(Vector3[] v3)
{
Vector2[] v2 = new Vector2[v3.Length];
for (int i = 0; i < v3.Length; i++)
{
v2[i] = new Vector2(v3[i].x, v3[i].y);
}
return v2;
}
public static Vector3[] v2Tv3(Vector2[] v2)
{
Vector3[] v3 = new Vector3[v2.Length];
for (int i = 0; i < v2.Length; i++)
{
v3[i] = new Vector3(v2[i].x, v2[i].y, 0);
}
return v3;
}
public static byte[] getTexture(Camera rtCamera,RenderTexture rt,Texture2D texture)
{
rtCamera.targetTexture = rt;
rtCamera.Render();
RenderTexture.active = rt;
texture.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
texture.Apply(false);
rtCamera.targetTexture = null;
RenderTexture.active = null;
return texture.EncodeToJPG();
}
}