- Home /
Debug.DrawLine from custom inspector
I'm making a custom inspector for a monobehaviour, and i wish to call Debug.DrawLine into the sceneview while the inspector is active. I've read that you have to call it from sceneview update, not from OnInspectorGUI or anywhere else. What would be the proper way of doing that?
public override void OnInspectorGUI()
{
obstacle = (Obstacle)target;
bool isPrefab = PrefabUtility.GetPrefabType(obstacle) == PrefabType.Prefab ? true : false;
obstacle.UpdateTransform();
obstacle.Center = EditorGUILayout.Vector2Field("Offset", obstacle.Center);
obstacle.Radius = EditorGUILayout.FloatField("Radius", obstacle.Radius);
if (!isPrefab && SceneView.lastActiveSceneView != null)
{
// Draw the obstacle using Debug.DrawLine()
obstacle.DrawBoundingBall(Color.red);
}
}
Answer by MathiasDG · Oct 26, 2015 at 09:46 AM
If anyone else is also searching for this, i found my way around it using OnDrawGizmos() on the actual monobehaviour, and not on the custo inspector. Trying to draw from the custom inspector was a complete failure for me.
Your answer
Follow this Question
Related Questions
Why is a added GameObject never at Position 0,0,0 ? 2 Answers
Add to an built in custom inspector 0 Answers
How to Hide/Show List or Array in the inspector based on a variable? 0 Answers
How to change array orders in the inspector 1 Answer
Custom Inspector "Multi-object editing not supported" 4 Answers