ExecuteInEditMode

I can’t get ExecuteInEditMode to work correctly. I want Update to run on a script component in the editor so I do like this:

using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]
public class jb_VisualRepData : MonoBehaviour
{
	public jb_VisualRep visualRep;

	public string groundMaterial;
	public float[] lodDistances;


	///////////////////////////////////////////////////////////
	// 
	///////////////////////////////////////////////////////////
	void Update()
	{
		if (Application.isEditor  visualRep != null)
		{
			visualRep.Update();

			if (lodDistances != null)
			{
				for (int i = 0; i < lodDistances.Length  i < visualRep.Lods.Count; ++i)
				{
					visualRep.Lods[i].SetDistance(lodDistances[i]);
				}
			}
		}
	}
}

But the update function only executes once. I’m using this script to update my lods when in the editor.

Thanks,
//ohm

Unfortunately, ExecuteInEditMode doesn’t do quite what you think. The Update function is certainly called for every frame update, but the updates don’t happen many times a second like they do during gameplay. In fact the updates happen only when the view changes, say when the user pans, zooms or rotates or when an object changes position or rotation.

Ok, thanks. That should be enough to update our LODS. I’ll do some testing.

//ohm