Hello, just started using Aline and noticed that drawing edit mode gizmos requires inheriting from MonoBehaviourGizmos.
We have lots of inheritence and this would cause a problem in which we would have to inherit almost all our base classes from MonoBehaviourGizmos instead of MonoBehaviour to use Aline in a handful of scripts.
Wanted to ask if there is another way of getting edit mode gizmos, without deriving from that?
Perhaps an interface could be used for this?
Or can one draw inside OnSceneGUI or from default unity gizmo events, like OnDrawGizmos or OnDrawGizmosSelected, like how it works with Update?
2nd Question;
Default Unity behaviour is, if a component is disabled, the OnDrawGizmos still draws. With Aline it doesn’t.
Could that be an option in the preferences window to also draw the disabled components gizmos with Aline?
No problem. You just have to inherit from the IDrawGizmos interface, and register your class in the constructor. Essentially copying the MonoBehaviourGizmos implementation.
There’s nothing inherently special about the MonoBehaviourGizmos, it’s just usually more convenient to inherit from that, than to implement it yourself.
public abstract class MyRandomClass : MonoBehaviour, IDrawGizmos {
public MyRandomClass() {
#if UNITY_EDITOR
DrawingManager.Register(this);
#endif
}
/** An empty OnDrawGizmosSelected method.
* Why an empty OnDrawGizmosSelected method?
* This is because only objects with an OnDrawGizmos/OnDrawGizmosSelected method will show up in Unity's menu for enabling/disabling
* the gizmos per object type (upper right corner of the scene view). So we need it here even though we don't use normal gizmos.
*
* By using OnDrawGizmosSelected instead of OnDrawGizmos we minimize the overhead of Unity calling this empty method.
*/
void OnDrawGizmosSelected () {
}
/** Draw gizmos for this object.
*
* The gizmos will be visible in the scene view, and the game view, if gizmos have been enabled.
*
* This method will only be called in the Unity Editor.
*
* \see \reflink{Draw}
*/
public virtual void DrawGizmos () {
}
}