It would be really convenient to have the following codes
[ExecuteInEditMode]
public class Something : MonoBehaviour {
#region Life cycle
#if UNITY_EDITOR
void EditorUpdate() {
// No, just nawh.
}
#endif
void Update() {
#if UNITY_EDITOR
if(Application.isPlaying) {
EditorUpdate();
return;
}
#endif
}
#endregion
}
written in such style:
public class Something : MonoBehaviour {
#region Life cycle
void EditorUpdate() {
// This is mean
}
void Update() {
// And lean!
}
#endregion
}
Come on, it’s not really anything hard to implement–
Editor only Unity messages sounds like a terrible idea, sorry.
OnDrawGizmos and similar is already too much Editor specific code bleeding into the UnityEngine namespace for me.
[ExecuteInEditMode] and [ExecuteAlways] already exist to fill this niche. A few extra lines of code never killed anyone.
1 Like
Hmm… Do you think it would be a good idea to have all these editor specific codes organized into a separate file, and further into the Assembly-CSharp-Editor
project? I mean they’d be still distinct from the custom editor & property drawer codes, since they don’t have much to do with the GUI stuffs, and need to be called every time when there’s a scene update.
I personally use my own assemblies and keep all editor code specific to editor-only assemblies. Gizmos are the only exception I really allow myself because there’s no good option otherwise. Attributes are another exception I suppose, particularly being a user of Odin.
Reason being is I want my gameplay to be the only code I’m looking at with anything runtime related. Editor code laced in between is noise that is better off not being in the way.
So my feature request would be to be able to do this in editor only classes, without it being inside my monobehaviours.
2 Likes