-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathEditorJsonUtility.bindings.cs
More file actions
40 lines (31 loc) · 1.39 KB
/
EditorJsonUtility.bindings.cs
File metadata and controls
40 lines (31 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using UnityEngine.Bindings;
namespace UnityEditor
{
[NativeHeader("Modules/JSONSerializeEditor/EditorJsonUtility.bindings.h")]
public static class EditorJsonUtility
{
[FreeFunction("ToEditorJsonInternal")]
private static extern string ToJsonInternal([NotNull] object obj, bool prettyPrint);
public static string ToJson(object obj) { return ToJson(obj, false); }
public static string ToJson(object obj, bool prettyPrint)
{
if (obj == null)
return "";
return ToJsonInternal(obj, prettyPrint);
}
[FreeFunction("FromEditorJsonOverwriteInternal", ThrowsException = true)]
private static extern void FromJsonOverwriteInternal([NotNull] string json, [NotNull] object objectToOverwrite);
public static void FromJsonOverwrite(string json, object objectToOverwrite)
{
if (string.IsNullOrEmpty(json))
return;
if (objectToOverwrite == null || (objectToOverwrite is UnityEngine.Object && !((UnityEngine.Object)objectToOverwrite)))
throw new ArgumentNullException("objectToOverwrite");
FromJsonOverwriteInternal(json, objectToOverwrite);
}
}
}