一个单独的序列化类, 可用于保存数据丶挂载UnityEngine.Object对象等操作;
[
C#
]继承: XOR.TsProperties → UnityEngine.MonoBehaviour
接口详情
方法 | 描述 |
---|---|
XOR.Serializables.ResultPair[] GetProperties() |
获取所有序列化成员 |
void SetProperty(string, object) |
(EditorOnly)设置键值 |
void SetPropertyListener(Action<string, object>) |
(EditorOnly)设置键值更新回调 |
示例场景:projects/Assets/Samples/02_TsProperties
示例typescript代码: projects/TsProject/src/samples/02_TsProperties.ts
export function init(target: CS.XOR.TsProperties) {
let properties = target?.GetProperties();
if (properties) {
let stringBuilder: string[] = [];
for (let i = 0; i < properties.Length; i++) {
let property = properties.get_Item(i);
stringBuilder.push(`${property.key}: ${property.value}`);
}
console.log(stringBuilder.join("\n"));
} else {
console.log("empty");
}
}
运行后将输出以下语句:
key0: 12
key1: false
key2: null