Inspector button for custom class

I know I can add buttons to monobehaviour based classes using editor extension class, but I can’t seem to find any solution on how to add buttons to my custom classes.

Namely I have a class that should store pos,rot,scale and some others stuff and I want it to have editor button in Inspector so I can just move the object as I want in editor then save its position values.

This is usefull for me when I have array of objects of this class to easily just move object and click save instead of writing down that stuff then entering it manually.

Thanks in advance!

ALLRIGHT! I’ll just post all of my code (It’s been done quite quick, but it’s tested!)

Class B:

using UnityEngine;
using System.Collections;

[System.Serializable]
public class ClassB 
{
	public string Name = "";

	public ClassB(int ID)
	{
		Name = "Button " + ID;
	}
}

Class A:

using UnityEngine;
using System.Collections;

public class ClassA : MonoBehaviour {

	public ClassB[] Arraything = new ClassB[5] { new ClassB(1), new ClassB(2), new ClassB(3), new ClassB(4), new ClassB(5) };
}

Editor Class :

using UnityEditor;
using UnityEngine;
using System.Collections;

[CustomEditor(typeof(ClassA))]
public class ClassAEditor : Editor
{
	bool IsFoldout = false;
	public override void OnInspectorGUI ()
	{
		ClassA Target = (ClassA)target;

		IsFoldout = EditorGUILayout.Foldout(IsFoldout, "Buttons");

		if(IsFoldout)
			for(int i = 0; i < Target.Arraything.Length; ++i)
			{
				GUILayout.Button(Target.Arraything*.Name);*
  •  	}*
    
  • }*
    }
    Remember that the Editor class needs to be in an Editor folder! Hope this works for ye!