Ejemplo n.º 1
0
        public static Vector3 DrawVector3(GUIContent label, Vector3 vec, Vector3 defaultValue, Object objectIAmOn,
                                          bool allowTransformDrop = false)
        {
            EditorGUILayout.BeginHorizontal();


            vec = EditorGUILayout.Vector3Field(label, vec);


            if (allowTransformDrop)
            {
                var       transformContent = new GUIContent("", "Assign the vectors value from a transform Position");
                Transform transform        = null;

                transform =
                    (Transform)EditorGUILayout.ObjectField(transformContent, transform, typeof(Transform), true,
                                                           GUILayout.Width(50));

                if (transform != null)
                {
                    EditorGUILayout.EndHorizontal();
                    return(transform.position);
                }
            }

            var resetContent = new GUIContent("R", "Resets the vector to  " + defaultValue);

            if (GUILayout.Button(resetContent, GUILayout.Width(25)))
            {
                Undo.RecordObject(objectIAmOn, "Vector 3 Reset");
                vec = defaultValue;
            }
            var copyContent = new GUIContent("C", "Copies the vectors data.");

            if (GUILayout.Button(copyContent, GUILayout.Width(25)))
            {
                CopyPaste.EditorCopy(vec);
            }
            var pasteContent = new GUIContent("P", "Pastes the vectors data.");

            if (GUILayout.Button(pasteContent, GUILayout.Width(25)))
            {
                Undo.RecordObject(objectIAmOn, "Vector 3 Paste");
                vec = CopyPaste.Paste <Vector3>();
            }

            EditorGUILayout.EndHorizontal();
            return(vec);
        }
Ejemplo n.º 2
0
        public static UnityEngine.Object CopyPastObjectButtons(UnityEngine.Object obj)
        {
            var CopyContent  = new GUIContent("Copy Data", "Copies the data.");
            var PasteContent = new GUIContent("Paste Data", "Pastes the data.");

            if (GUILayout.Button(CopyContent))
            {
                CopyPaste.EditorCopy(obj);
            }
            if (GUILayout.Button(PasteContent))
            {
                Undo.RecordObject(obj, "Before Paste Settings");
                CopyPaste.EditorPaste(ref obj);
            }
            return(obj);
        }