Select Page

When we use Gizmos API for drawing objects, the object is drawn in world space and it won’t get scaled depending on the camera zoom in the scene view, to fix this, you need to scale the size of gizmo, by using HandleUtility.GetHandleSize: (The below is an example usage of this method)

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

public class ClimbPoint : MonoBehaviour
{

    [SerializeField]
    protected Transform leftHand;
    [SerializeField]
    protected Transform rightHand;

#if UNITY_EDITOR
    protected virtual void OnDrawGizmos()
    {
        Gizmos.color = Color.red;
        Gizmos.DrawWireSphere(leftHand.position, HandleUtility.GetHandleSize(leftHand.position));
        Gizmos.DrawWireSphere(rightHand.position, HandleUtility.GetHandleSize(rightHand.position));
    }
#endif

}

References:

Thanks for reading!