-
-
Save Novack/cbe8061de18a2d73ef678216ce9ab77c 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; | |
using UnityEditor; | |
using UnityEngine; | |
public class CopyPasteValues | |
{ | |
static string copyBuffer; | |
static Type copyType; | |
[MenuItem("CONTEXT/Component/Copy Values With Json")] | |
static void Copy(MenuCommand command) | |
{ | |
copyType = command.context.GetType(); | |
copyBuffer = EditorJsonUtility.ToJson(command.context); | |
} | |
[MenuItem("CONTEXT/Component/Paste Values With Json")] | |
static void Paste(MenuCommand command) | |
{ | |
EditorJsonUtility.FromJsonOverwrite(copyBuffer, command.context); | |
} | |
[MenuItem("CONTEXT/Component/Paste Values With Json", validate = true)] | |
static bool PasteValidate(MenuCommand command) | |
{ | |
var type = command.context.GetType(); | |
return !string.IsNullOrEmpty(copyBuffer) && copyType != null && copyType.IsAssignableFrom(type); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment