47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using Convention;
|
|
using UnityEngine;
|
|
|
|
namespace Demo.Game
|
|
{
|
|
public class DDT : ScriptableObject
|
|
{
|
|
public string BindingDataJson => $"{ScriptPath}.json";
|
|
|
|
public static DDT Make()
|
|
{
|
|
return new GameObject().AddComponent<DDT>();
|
|
}
|
|
|
|
public List<float> Datas = new();
|
|
|
|
[ScriptableCall(@"
|
|
添加float数据, 随后可以用对象路径+索引获取变量值,
|
|
e.g: CameraObject/DDT[3], 获取CameraObject/DDT对象路径下DDT数据中的第四个值
|
|
")]
|
|
public void Add(string value)
|
|
{
|
|
Datas.Add(float.Parse(value));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 从特定的json中读取数据
|
|
/// </summary>
|
|
[ScriptableCall(@"从特定的json中读取数据")]
|
|
public void Load()
|
|
{
|
|
var file = new ToolFile(BindingDataJson);
|
|
if (file.Exists() == false)
|
|
{
|
|
file.MustExistsPath()
|
|
.SaveAsJson<List<float>>(new());
|
|
Datas.Clear();
|
|
}
|
|
else
|
|
{
|
|
Datas = file.LoadAsJson<List<float>>();
|
|
}
|
|
}
|
|
}
|
|
}
|