public static Vector3 DrawVector3(GUIContent label, Vector3 vec, Vector3 defaultValue, Obj objectIAmOn, out bool GUIChanged) { using (Disposables.IndentSet(1)) { using (Disposables.HorizontalScope()) { using (var cc = Disposables.ChangeCheck()) { vec = EditorGUILayout.Vector3Field(label, vec); GUIChanged = cc.changed; } var cachedGuiColor = GUI.color; using (Disposables.HorizontalScope(EditorStyles.toolbar)) { var resetBtn = FoCsGUI.Layout.Button(ResetContent, EditorStyles.toolbarButton, GUILayout.Width(25)); var copyBtn = FoCsGUI.Layout.Button(CopyContent, EditorStyles.toolbarButton, GUILayout.Width(25)); var pasteBtn = FoCsGUI.Layout.Button(PasteContent, EditorStyles.toolbarButton, GUILayout.Width(25)); if (resetBtn) { Undo.RecordObject(objectIAmOn, "Vector 3 Reset"); vec = defaultValue; GUIChanged = true; } else if (copyBtn) { CopyPasteUtility.EditorCopy(vec); } else if (pasteBtn) { Undo.RecordObject(objectIAmOn, "Vector 3 Paste"); vec = CopyPasteUtility.Paste <Vector3>(); GUIChanged = true; } GUI.color = cachedGuiColor; } } } return(vec); }
public static Obj CopyPastObjectButtons(Obj obj) { var canCopy = CopyPasteUtility.CanCopy(obj); var guiEnableCache = GUI.enabled; var copyBuff = CopyPasteUtility.CopyBuffer; if (canCopy) { var isType = CopyPasteUtility.IsTypeInBuffer(obj, copyBuff); FoCsGUI.GUIEventBool pasteEvent; GUI.enabled = true; var copyEvent = FoCsGUI.Layout.Button(CP_CopyContent, EditorStyles.toolbarButton); GUI.enabled = guiEnableCache; using (Disposables.ColorChanger(isType? GUI.color : Color.red)) { var pasteContent = new GUIContent("Paste", "Pastes the data.\n" + copyBuff.Substring(0, copyBuff.Length >= 512? 512 : copyBuff.Length)); if (!isType) { pasteContent.tooltip = "Warning, this will attempt to paste any fields with the same name.\n" + pasteContent.tooltip; } pasteEvent = FoCsGUI.Layout.Button(pasteContent, EditorStyles.toolbarButton); } if (copyEvent) { CopyPasteUtility.Copy(obj); return(obj); } if (!pasteEvent) { return(obj); } Undo.RecordObject(obj, "Before Paste Settings"); CopyPasteUtility.Paste(ref obj, copyBuff, true); return(obj); } var canEditorCopy = CopyPasteUtility.CanEditorCopy(obj); if (canEditorCopy) { var isType = CopyPasteUtility.IsTypeInBuffer(obj, copyBuff); FoCsGUI.GUIEventBool pasteEvent; GUI.enabled = true; var copyEvent = FoCsGUI.Layout.Button(CP_EditorCopyContent, EditorStyles.toolbarButton); GUI.enabled = guiEnableCache; using (Disposables.ColorChanger(isType? GUI.color : Color.red)) { var pasteContent = new GUIContent("Paste (E)", $"Pastes the data. (using the EditorJSONUtility)\n{copyBuff.Substring(0, copyBuff.Length >= 512? 512 : copyBuff.Length)}"); if (!isType) { pasteContent.tooltip = "Warning, this will attempt to paste any fields with the same name.\n" + pasteContent.tooltip; } pasteEvent = FoCsGUI.Layout.Button(pasteContent, EditorStyles.toolbarButton); } if (copyEvent) { CopyPasteUtility.EditorCopy(obj); return(obj); } if (!pasteEvent) { return(obj); } Undo.RecordObject(obj, "Before Paste Settings"); CopyPasteUtility.EditorPaste(ref obj, copyBuff, true); } return(obj); }