2020-UnityHelper v3Tv2

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();
    }
}

 

上一篇:FGUI在Container容器中的物体使用LocalToGlobal,获取屏幕坐标


下一篇:Hutool中DateUtil常用方法(格式化日期Date2Str、Str2Date、获取一天的开始时间和结束时间、日期时间差)