Пример #1
0
        public static Obj CopyPastObjectButtons(Obj obj)
        {
            if (CopyPasteUtility.CanCopy(obj))
            {
                using (new GUILayout.HorizontalScope())
                {
                    var CopyContent = new GUIContent("Copy Data", "Copies the data.");
                    if (GUILayout.Button(CopyContent, EditorStyles.toolbarButton))
                    {
                        CopyPasteUtility.Copy(obj);
                    }
                    var isType = CopyPasteUtility.IsTypeInBuffer(obj);
                    using (new EditorColorChanger(isType? GUI.color : Color.red))
                    {
                        var PasteContent = new GUIContent("Paste Data", "Pastes the data.\n" + CopyPasteUtility.CopyBuffer);

                        if (!isType)
                        {
                            PasteContent.tooltip = "Warning, this will attempt to paste any feilds with the same name.\n" + PasteContent.tooltip;
                        }

                        if (GUILayout.Button(PasteContent, EditorStyles.toolbarButton))
                        {
                            Undo.RecordObject(obj, "Before Paste Settings");
                            CopyPasteUtility.Paste(ref obj);
                        }
                    }
                    return(obj);
                }
            }
            if (CopyPasteUtility.CanEditorCopy(obj))
            {
                using (new GUILayout.HorizontalScope())
                {
                    var CopyContent = new GUIContent("(Editor) Copy Data", "Copies the data.");

                    if (GUILayout.Button(CopyContent, EditorStyles.toolbarButton))
                    {
                        CopyPasteUtility.EditorCopy(obj);
                    }
                    var PasteContent = new GUIContent("(Editor) Paste Data", "Pastes the data.\n" + CopyPasteUtility.CopyBuffer);

                    var isType = CopyPasteUtility.IsTypeInBuffer(obj);
                    using (new EditorColorChanger(isType? GUI.color : Color.red))
                    {
                        if (!isType)
                        {
                            PasteContent.tooltip = "Warning, this will attempt to paste any feilds with the same name.\n" + PasteContent.tooltip;
                        }

                        if (GUILayout.Button(PasteContent, EditorStyles.toolbarButton))
                        {
                            Undo.RecordObject(obj, "Before Paste Settings");
                            CopyPasteUtility.EditorPaste(ref obj);
                        }
                    }
                }
                return(obj);
            }
            return(obj);
        }