Created
          July 12, 2022 11:12 
        
      - 
      
- 
        Save INeatFreak/175e229da2fe35a7e13483445d02d44a to your computer and use it in GitHub Desktop. 
Revisions
- 
        INeatFreak created this gist Jul 12, 2022 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ void DrawCameraOrientedWireSphere(Vector3 position, float radius, Color color) { UnityEditor.Handles.matrix = Matrix4x4.TRS(Vector3.zero, transform.rotation, Vector3.one); UnityEditor.Handles.color = color; UnityEditor.Handles.DrawWireDisc(position, Vector3.right, radius); UnityEditor.Handles.DrawWireDisc(position, Vector3.up, radius); UnityEditor.Handles.DrawWireDisc(position, Vector3.forward, radius); if(Camera.current.orthographic) { Vector3 normal = position - UnityEditor.Handles.inverseMatrix.MultiplyVector(Camera.current.transform.forward); float sqrMagnitude = normal.sqrMagnitude; float num0 = radius * radius; UnityEditor.Handles.DrawWireDisc(position - num0 * normal / sqrMagnitude, normal, radius); } else { Vector3 normal = position - UnityEditor.Handles.inverseMatrix.MultiplyPoint(Camera.current.transform.position); float sqrMagnitude = normal.sqrMagnitude; float num0 = radius * radius; float num1 = num0 * num0 / sqrMagnitude; float num2 = Mathf.Sqrt(num0 - num1); UnityEditor.Handles.DrawWireDisc(position - num0 * normal / sqrMagnitude, normal, num2); } }