46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
using UnityEngine;
|
|
using static XPlugin.Data.JsonLiteDB.JsonLiteDB;
|
|
|
|
public class ObjectInfo
|
|
{
|
|
|
|
public int ID;
|
|
|
|
public Vector3 Position;
|
|
|
|
public Vector3 Angle;
|
|
public ObjectInfo(TableReader table)
|
|
{
|
|
ID = table["ID"].OptInt();
|
|
string position = table["Position"].OptString();
|
|
Position = StringToVector(position);
|
|
string angle = table["Angle"].OptString();
|
|
Angle = StringToVector(angle);
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector3 StringToVector(string input)
|
|
{
|
|
if (input == "")
|
|
{
|
|
return Vector3.zero;
|
|
}
|
|
// 去掉字符串中的括号和空格
|
|
input = input.Replace("(", "").Replace(")", "").Replace(" ", "");
|
|
|
|
// 将字符串按逗号分割成三个部分
|
|
string[] parts = input.Split(',');
|
|
|
|
// 将每个部分解析为浮点数
|
|
float x = float.Parse(parts[0]);
|
|
float y = float.Parse(parts[1]);
|
|
float z = float.Parse(parts[2]);
|
|
|
|
// 创建并返回 Vector3
|
|
return new Vector3(x, y, z);
|
|
}
|
|
|
|
}
|