Last active
January 22, 2020 11:38
-
-
Save CapitanLiteral/f7291cb8036161233383655bfec3e522 to your computer and use it in GitHub Desktop.
This file contains 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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
public static class EditorWindowExtensions | |
{ | |
public static string Save(this EditorWindow window) | |
{ | |
var data = JsonUtility.ToJson(window, false); | |
EditorPrefs.SetString(window.GetType().ToString(), data); | |
return data; | |
} | |
public static string Load(this EditorWindow window) | |
{ | |
var data = EditorPrefs.GetString(window.GetType().ToString(), JsonUtility.ToJson(window, false)); | |
JsonUtility.FromJsonOverwrite(data, window); | |
return data; | |
} | |
public static string Save(this Editor window) | |
{ | |
var data = JsonUtility.ToJson(window, false); | |
EditorPrefs.SetString(window.GetType().ToString(), data); | |
return data; | |
} | |
public static string Load(this Editor window) | |
{ | |
var data = EditorPrefs.GetString(window.GetType().ToString(), JsonUtility.ToJson(window, false)); | |
JsonUtility.FromJsonOverwrite(data, window); | |
return data; | |
} | |
public static string SaveOnlyForThisProject(this Editor window) | |
{ | |
var data = JsonUtility.ToJson(window, false); | |
EditorPrefs.SetString(System.IO.Directory.GetCurrentDirectory()+"\\"+window.GetType().ToString(), data); | |
return data; | |
} | |
public static string LoadOnlyForThisProject(this Editor window) | |
{ | |
var data = EditorPrefs.GetString(System.IO.Directory.GetCurrentDirectory()+"\\"+window.GetType().ToString(), JsonUtility.ToJson(window, false)); | |
JsonUtility.FromJsonOverwrite(data, window); | |
return data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment