Reputation: 139
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
}
Upvotes: 0
Views: 13143
Reputation: 9
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);
}
Upvotes: 0
Reputation: 139
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.
Upvotes: 1
Reputation: 103
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);
}
}
Upvotes: 2