Why does it not draw the circle gizmo in editor?

11.1k Views Asked by At

I am trying to draw a simple circle in the editor. I found this method but I don't understand why it doesn't work. How can I draw the circle in the editor? Thank you.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif

public class Assigments : MonoBehaviour
{
    Transform obj;

    [Range(0, 3f)]
    public float radious = 1f;

#if UNITY_EDITOR
    private void OnDrawGizmos()
    {
        Debug.Log("works");
        Vector2 origin = transform.position;
        Handles.color = Color.red;
        Handles.DrawWireDisc(origin, new Vector3(0, 0, 1), radious);
    }
#endif
}
3

There are 3 best solutions below

1
On BEST ANSWER

Try this.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Assigments : MonoBehaviour
{
    public float lookRadius = 10f;
    void OnDrawGizmosSelected()
    {
        Gizmos.color = Color.red;
        Gizmos.DrawWireSphere(transform.position, lookRadius);
    }
}
0
On

So! I did a huge mistake. I did not selected the "gizmo" button. Actually none of my gizmos were showing up. I taught that only the one made by me wasn't showing up. After I selected the Gizmo button everything was working properly.

PS: The code I written works perfectly. So the solution presented by OxPikolo.

Thank you and sorry for being a noob, lol.

0
On

Also you can try Handles.DrawWireArc:

    private void OnDrawGizmosSelected()
    {
        float radius = 3f;
        Handles.color = Color.cyan;
        // DrawWireArc(Vector3 center, Vector3 normal, Vector3 from, float angle, float radius, float thickness = 0.0f);
        Handles.DrawWireArc(transform.position, Vector3.up, Vector3.forward, 360, radius);
    }