43 lines
1.0 KiB
C#
43 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public static class VectorExtend
|
|
{
|
|
public static Vector3 Parse(this Vector3 self, string str)
|
|
{
|
|
return new Vector3(float.Parse(str.Split(',')[0]), float.Parse(str.Split(',')[2]), float.Parse(str.Split(',')[2]));
|
|
}
|
|
|
|
public static void TraSet(this Transform self, Vector3 v)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public static class Vector3Extension
|
|
{
|
|
/// <summary>
|
|
/// 将xyz值放入一个长度为3的float数组中
|
|
/// </summary>
|
|
/// <param name="self">三维向量</param>
|
|
/// <returns>float数组</returns>
|
|
public static float[] ToArray(this Vector3 self)
|
|
{
|
|
float[] retArray = new float[3];
|
|
retArray[0] = self.x;
|
|
retArray[1] = self.y;
|
|
retArray[2] = self.z;
|
|
return retArray;
|
|
}
|
|
/// <summary>
|
|
/// 转四元数
|
|
/// </summary>
|
|
/// <param name="self">三维向量</param>
|
|
/// <returns>四元数</returns>
|
|
public static Quaternion ToQuaternion(this Vector3 self)
|
|
{
|
|
return Quaternion.Euler(self);
|
|
}
|
|
}
|