Created
May 13, 2025 09:36
-
-
Save karljj1/ace07bde835fef2dd85e405141945f2c to your computer and use it in GitHub Desktop.
Export an assets data as JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
public class ExportAsJson | |
{ | |
[MenuItem("CONTEXT/Object/Export As Json")] | |
public static void DoExportAsJson(MenuCommand command) | |
{ | |
var json = EditorJsonUtility.ToJson(command.context, true); | |
var path = EditorUtility.SaveFilePanel("Save JSON", "", command.context.name + ".json", "json"); | |
if (string.IsNullOrEmpty(path)) | |
return; | |
System.IO.File.WriteAllText(path, json); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment