How to get component from an Object

I want to know what kind(type) of script this Object is but I don’t know how,

The code:

Object o;

void OnGUI()
{
    o = (Object)EditorGUILayout.ObjectField(script, typeof(Object), false );
}

I think you can use

o.GetType ();

to get the type of object.

When selecting script objects you can use the following instead to ensure that the correct asset is selected. You can then access the name of the script via the name property. To access further information about the class type itself you can use the GetClass() method.

MonoScript script;

void OnGUI() {
    script = EditorGUILayout.ObjectField(script, typeof(MonoScript), false) as MonoScript;
    if (script != null) {
        // The following will work generally...
        string theNameOfYourScript = script.name;

        // Though if you are using namespaces then you will
        // need the following variety instead:
        System.Type scriptType = script.GetClass();
        string theNameOfYourScript = scriptType.FullName;
    }
}

For more information about MonoScript.GetClass see: