I am currently running through the videos on Editor Scripting and am trying to replicate an editor script that spawns a prefab and vector3.Zero.
I have this code:
My script that is on the GameObject:
using UnityEngine;
using System.Collections;
public class aScript : MonoBehaviour {
public GameObject obj;
public void BuildObject(){
Instantiate (obj, Vector3.zero, Quaternion.identity);
}
}
And my script in the Editor folder:
using UnityEngine;
using System.Collections;
using UnityEditor;
public class aScriptEditor : Editor {
[CustomEditor(typeof(aScript))]
public override void OnInspectorGUI(){
DrawDefaultInspector ();
aScript myScript = (aScript)target;
if (GUILayout.Button ("Spawn a cube")) {
myScript.BuildObject();
}
}
}
This is what I see in my inspector:
The button does not appear.