I want to create an editor button in my script to call some methods, and I’ve looked at tutorial on unity site how to do this, and i’ve made a class that derives from editor.
Here is my base class:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class AntTowerDemo : MonoBehaviour {
//public field, methods and stuff
}
and here is my editor class:
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(AntTowerDemo))]
public class AntTowerEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
AntTowerDemo atd = (AntTowerDemo)target;
if (GUILayout.Button("Save Ant Tower Data"))
atd.SaveData();
}
}
Problem is I get the error where I should see the class fields in Inspector, I see “Multi-object editing not supported”.
Also when I click on the GameObject containing the script I get an error “Instance of AntTowerEditor couldn’t be created because there is no script with that name.”
I’ve made sure that I have two separate scripts and even tried declaring editor extension class inside of AntTowerDemo class but I get the same error every time.
I’ve got 4.3.1 something Unity and as I see in that tutorial it says that it’s been tested in that Unity. Do I need Unity pro for this functionality?