Example #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            float height       = singleLine * 1.25f;
            float centerAmount = (height - singleLine) / 2;
            float titleWidth   = EditorHelpers.GetStringLengthinPix(label.text);
            float widthVector  = position.width - (height * 3) - titleWidth;

            EditorGUI.LabelField(new Rect(position.x, position.y, titleWidth, height), label);
            EditorGUI.PropertyField(new Rect(position.x + titleWidth, position.y + centerAmount, widthVector, height),
                                    property, GUIContent.none);

            var resetsContent = new GUIContent("R", "Resets the vector to  " + Vector4.zero);

            if (GUI.Button(new Rect(position.x + titleWidth + widthVector, position.y, height, height), resetsContent))
            {
                property.vector4Value = Vector4.zero;
            }

            var copyContent = new GUIContent("C", "Copies the vectors data.");

            if (GUI.Button(new Rect(position.x + titleWidth + widthVector + height, position.y, height, height),
                           copyContent))
            {
                CopyPaste.EditorCopy(property.vector4Value);
            }

            var pasteContent = new GUIContent("P", "Pastes the vectors data.");

            if (GUI.Button(
                    new Rect(position.x + titleWidth + widthVector + height + height, position.y, height, height),
                    pasteContent))
            {
                property.vector4Value = CopyPaste.Paste <Vector4>();
            }
        }
Example #2
0
    public static object CopyPastObjectButtons(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))
        {
            CopyPaste.EditorPaste(ref obj);
        }

        return(obj);
    }
Example #3
0
    //[Obsolete("Use property drawer instead")]
    public static Vector3 DrawVector3(GUIContent label, Vector3 vec, Vector3 defualtValue, bool allowTransformDrop = false)
    {
        EditorGUILayout.BeginHorizontal();
        vec = EditorGUILayout.Vector3Field(label, vec);

        if (allowTransformDrop)
        {
            var       transformContent = new GUIContent("", "Asign 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  " + defualtValue);

        if (GUILayout.Button(resetContent, GUILayout.Width(25)))
        {
            vec = defualtValue;
        }

        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)))
        {
            vec = CopyPaste.Paste <Vector3>();
        }

        EditorGUILayout.EndHorizontal();

        return(vec);
    }