Version: 2020.2
public static string ToJson (object obj);
public static string ToJson (object obj, bool prettyPrint);

参数

obj 要转换为 JSON 形式的对象。
prettyPrint 如果为 true,则格式化输出以实现可读性。如果为 false,则格式化输出以实现最小大小。默认为 false。

返回

string JSON 格式的对象数据。

描述

生成对象的 JSON 表示形式。

这类似于 JsonUtility.ToJson,但它支持任何引擎对象。输出将包含的字段与可通过 SerializedObject API 访问的字段或通过 YAML 序列化形式的对象找到的字段相同。


Did you find this page useful? Please give it a rating: