How can I rotate an object in code at edit time?

I want a game object to continuously rotate inside my scene view without the need for me to do anything.

How do I go about this? I am aware of a few different solutions which I don’t fully understand and/or have had problems getting to work(Using a custom inspector). Can anyone outline the simplest method which to do this?

Many thanks.

This Answer seems to have pointed me in the right direction to solving your problem.

You need to hook up to the EditorApplication.update callback function.

[ExecuteInEditMode]
public class test : MonoBehaviour 
{
	public float rotation;

	void OnEnable()
	{
		EditorApplication.update += EditorUpdate;
	}

	void EditorUpdate () 
	{
		this.transform.Rotate(new Vector3(0,rotation,0));
	}

	void OnDisable()
	{
		EditorApplication.update -= EditorUpdate;
	}
}

On every Update call you have to change the rotation of the object.

Say you want to change the Y rotation with 10 degrees on every Update.

gameObject.transform.rotation.eulerAngles = Quaternion.Euler(gameObject.transform.rotation.eulerAngles.x, gameObject.transform.rotation.eulerAngles.y + 10f, gameObject.transform.rotation.eulerAngles.z);

Use [ExecuteInEditMode] attribute on your MonoBehaviour class, and unity will call basic messages on it even in edit mode. But if you use Update(), it won’t be continuous in edit mode, because Updates are only called when you move / change something. My guess is that the edit view is not even rendered if you don’t interact with it (perhaps with some special exception for the particles preview?), so no continuous motion in editor is possible.

you can make an editor select your objects or find them by code then on the Update() of the editor window make the changes you want, I was having fun making some editor some days ago and went through that.
good luck and happy coding