Using handles to edit custom classes

Is there a way to override Unity's handles? I mean, I want to use the rotation gizmo to modify a property other than transform.rotation. I've got this so far:

using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(Foo))]
public class FooEditor : Editor 
{
    public override void OnInspectorGUI ()
    {
        DrawDefaultInspector();
    }

    public void OnSceneGUI()
    {
        Foo foo = (Foo)target;

        foo.rotation = Handles.RotationHandle(foo.rotation, foo.transform.position);
    }
}

And my Foo class:

using UnityEngine;

public class Foo : MonoBehaviour 
{
    public Vector3 position;
    public Quaternion rotation;
    public Vector3 size;
}

I want that when the user modify size, position or rotation through one of the Unity's default gizmos, my class get modified and not the current selected transform. If there is no way of doing that, is there a way to disable the rendering of Unity's default gizmos?

I think that your problem is that you are accessing a field that is set in the superclass without a overriding field in your code. What the upshot of this OO-speak is that you need to rename the variable in your class to something like fooRotation, or just changing the capitalization (C# is case sensitive).

You might try

using UnityEngine;

public class Foo : MonoBehaviour 
{
    public Vector3 Position;
    public Quaternion Rotation;
    public Vector3 Size;
}

and calling Foo foo = (Foo)target;

    foo.Rotation= Handles.RotationHandle(foo.Rotation, foo.transform.position);

I had this pain myself; eventually I tracked it down to the Tools class.

The trick is, in your custom inspector (ie the one that derives from Editor), add this code to the OnEnable() and OnDisable() functions:

void OnEnable(){
	Tools.hidden = true; //hide default tools when activated
}

void OnDisable(){
	Tools.hidden = false; //unhide default tools when deactived
}

Thus you can ‘override’ the default tools with your own custom handles without the default one getting in the way.