How to execute a method from a PropertyDrawer?

Hi,

How can i execute a method that belong to a script that attached to some GameObject from a PropertyDrawer?

for example i have these classes:

    using UnityEngine;
    [System.Serializable]
    public class Data{
    
    	public Vector3 size = Vector3.zero;
    	public float speed;
    }
    
    
    using UnityEngine;
    using System.Collections;
    [ExecuteInEditMode]
    public class Test: MonoBehaviour {
    	public Data data;
    	public void DoSomething(){/*..*/}
    
    }
    
    using UnityEngine;
    using UnityEditor;
    [CustomPropertyDrawer(typeof(Data)]
    public class DataDrawer : PropertyDrawer {
    
    	public override void OnGUI (Rect pos, SerializedProperty prop, GUIContent label)
    	{
    		
    		SerializedProperty size  = prop.FindPropertyRelative ("size");
    		SerializedProperty speed = prop.FindPropertyRelative ("speed");
    		...
    
    		if( GUI.Button(new Rect ( 0 , 0,100, 20),"Click Me" ) ){
    			//HOW TO EXECUTE DoSomething() method from this point?	
    		}
    		
    	}
    	
    	
    }

I need to call “DoSomething” method that belong to “Test” class from the PropertyDrawer that decorate the “Data” class.

Help Please…
Thanks

Well, I guess that normally it is actually bad practice to use something of the class you attatch your data to (Beecause then Data can only be added to that specific class.

If you don’t mind though, the following line will execute your method.

(prop.serializedObject.targetObject as Test).DoSomething();