- Home /
Adding a Custom Button to the Inspector
Hi, i want to write an importer Script with a button in the Inspector. But i get allways the Message "multi-object editing not supported" and the only thing that i selected was the GameObjekt with the Script attached.
I have tested these example (Link) but i got the same Message.
Edit:
ObjectBuilderScript:
using UnityEngine;
using System.Collections;
[AddComponentMenu("Tiled Map/Tiled Map Component")]
public class ObjectBuilderScript : MonoBehaviour
{
public GameObject obj;
public Vector3 spawnPoint;
public void BuildObject()
{
Instantiate(obj, spawnPoint, Quaternion.identity);
}
}
ObjectBuilderEditor:
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(ObjectBuilderScript))]
public class ObjectBuilderEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
ObjectBuilderScript myScript = (ObjectBuilderScript)target;
if(GUILayout.Button("Build Object"))
{
myScript.BuildObject();
}
}
}
problem.png
(28.4 kB)
Comment
$$anonymous$$e wont work and sometimes i get the $$anonymous$$essage "Instance of ObjectBuilderEditor couldn't be created because there is no script with that name."
ahhh, that's it then. $$anonymous$$ake sure you class ($$anonymous$$onoBehaviour) name has the same as your .cs file :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613140728im_/https://answers.unity.com/themes/thub/images/avi.jpg)