The GUILayout.Button() method displays a button in the inspector when you select the gameObject which are you referencing.
For example... this code (customButton.cs) adds a button to the inspector in the script "OpenFileButtonScript.cs" which calls its OpenDialog() method.
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(OpenFileButtonScript))]
public class customButton : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
OpenFileButtonScript myScript = (OpenFileButtonScript)target;
if (GUILayout.Button("Open File"))
{
myScript.OpenDialog();
}
}
}
This is the "OpenFileButtonScript.cs" script:
using UnityEngine;
using System.Collections;
using UnityEditor;
public class OpenFileButtonScript : MonoBehaviour {
public string path;
public void OpenDialog()
{
path = EditorUtility.OpenFilePanel(
"Open file",
"",
"*");
}
}
I hope this can help you. For more info about buttons see this videotutorial