- Home /
Question by
wolfenstien98 · Jan 31, 2016 at 09:04 PM ·
c#editor-scriptinggizmosdrawing
Drawing Ellipsoid
I would like to have a Gizmo that is an ellipsoid centered around a point, that has a different height, width, and depth. I have tried to figure out how to do it with the Handles.DrawBezier but I wasn't able to figure out the start and end tangents. Any help would be amazing; this one is really stumping me.
Comment
Best Answer
Answer by wolfenstien98 · Feb 01, 2016 at 05:28 AM
So I was able to solve the problem. If anyone else needs to something like this, this is how.
//Y-Z Ring
Handles.DrawBezier(new Vector3(drawPos.x, drawPos.y + src.effectSize.y, drawPos.z), new Vector3(drawPos.x, drawPos.y, drawPos.z + src.effectSize.z), src.transform.TransformPoint(new Vector3(0, src.effectSize.y, src.effectSize.z / 2)), src.transform.TransformPoint(new Vector3(0, src.effectSize.y / 2, src.effectSize.z)), col, Texture2D.whiteTexture, size);
Handles.DrawBezier(new Vector3(drawPos.x, drawPos.y + src.effectSize.y, drawPos.z), new Vector3(drawPos.x, drawPos.y, drawPos.z - src.effectSize.z), src.transform.TransformPoint(new Vector3(0, src.effectSize.y, -src.effectSize.z / 2)), src.transform.TransformPoint(new Vector3(0, src.effectSize.y / 2, -src.effectSize.z)), col, Texture2D.whiteTexture, size);
Handles.DrawBezier(new Vector3(drawPos.x, drawPos.y - src.effectSize.y, drawPos.z), new Vector3(drawPos.x, drawPos.y, drawPos.z + src.effectSize.z), src.transform.TransformPoint(new Vector3(0, -src.effectSize.y, src.effectSize.z / 2)), src.transform.TransformPoint(new Vector3(0, -src.effectSize.y / 2, src.effectSize.z)), col, Texture2D.whiteTexture, size);
Handles.DrawBezier(new Vector3(drawPos.x, drawPos.y - src.effectSize.y, drawPos.z), new Vector3(drawPos.x, drawPos.y, drawPos.z - src.effectSize.z), src.transform.TransformPoint(new Vector3(0, -src.effectSize.y, -src.effectSize.z / 2)), src.transform.TransformPoint(new Vector3(0, -src.effectSize.y / 2, -src.effectSize.z)), col, Texture2D.whiteTexture, size);
//X-Y Ring
Handles.DrawBezier(new Vector3(drawPos.x + src.effectSize.x, drawPos.y, drawPos.z), new Vector3(drawPos.x, drawPos.y + src.effectSize.y, drawPos.z), src.transform.TransformPoint(new Vector3((src.effectSize.x), (src.effectSize.y / 2), 0)), src.transform.TransformPoint(new Vector3((src.effectSize.x / 2), (src.effectSize.y), 0)), col, Texture2D.whiteTexture, size);
Handles.DrawBezier(new Vector3(drawPos.x - src.effectSize.x, drawPos.y, drawPos.z), new Vector3(drawPos.x, drawPos.y + src.effectSize.y, drawPos.z), src.transform.TransformPoint(new Vector3(-(src.effectSize.x), (src.effectSize.y / 2), 0)), src.transform.TransformPoint(new Vector3(-(src.effectSize.x / 2), (src.effectSize.y), 0)), col, Texture2D.whiteTexture, size);
Handles.DrawBezier(new Vector3(drawPos.x + src.effectSize.x, drawPos.y, drawPos.z), new Vector3(drawPos.x, drawPos.y - src.effectSize.y, drawPos.z), src.transform.TransformPoint(new Vector3((src.effectSize.x), -(src.effectSize.y / 2), 0)), src.transform.TransformPoint(new Vector3((src.effectSize.x / 2), -(src.effectSize.y), 0)), col, Texture2D.whiteTexture, size);
Handles.DrawBezier(new Vector3(drawPos.x - src.effectSize.x, drawPos.y, drawPos.z), new Vector3(drawPos.x, drawPos.y - src.effectSize.y, drawPos.z), src.transform.TransformPoint(new Vector3(-(src.effectSize.x), -(src.effectSize.y / 2), 0)), src.transform.TransformPoint(new Vector3(-(src.effectSize.x / 2), -(src.effectSize.y), 0)), col, Texture2D.whiteTexture, size);
//X-Z Ring
Handles.DrawBezier(new Vector3(drawPos.x + src.effectSize.x, drawPos.y, drawPos.z), new Vector3(drawPos.x, drawPos.y, drawPos.z + src.effectSize.z), src.transform.TransformPoint(new Vector3((src.effectSize.x), 0, (src.effectSize.z /2))), src.transform.TransformPoint(new Vector3((src.effectSize.x / 2), 0, (src.effectSize.z))), col, Texture2D.whiteTexture, size);
Handles.DrawBezier(new Vector3(drawPos.x - src.effectSize.x, drawPos.y, drawPos.z), new Vector3(drawPos.x, drawPos.y, drawPos.z + src.effectSize.z), src.transform.TransformPoint(new Vector3(-(src.effectSize.x), 0, (src.effectSize.z /2))), src.transform.TransformPoint(new Vector3(-(src.effectSize.x / 2), 0, (src.effectSize.z))), col, Texture2D.whiteTexture, size);
Handles.DrawBezier(new Vector3(drawPos.x + src.effectSize.x, drawPos.y, drawPos.z), new Vector3(drawPos.x, drawPos.y, drawPos.z - src.effectSize.z), src.transform.TransformPoint(new Vector3((src.effectSize.x), 0, -(src.effectSize.z /2))), src.transform.TransformPoint(new Vector3((src.effectSize.x / 2), 0, -(src.effectSize.z))), col, Texture2D.whiteTexture, size);
Handles.DrawBezier(new Vector3(drawPos.x - src.effectSize.x, drawPos.y, drawPos.z), new Vector3(drawPos.x, drawPos.y, drawPos.z - src.effectSize.z), src.transform.TransformPoint(new Vector3(-(src.effectSize.x), 0, -(src.effectSize.z /2))), src.transform.TransformPoint(new Vector3(-(src.effectSize.x / 2), 0, -(src.effectSize.z))), col, Texture2D.whiteTexture, size);
Your answer
![](https://koobas.hobune.stream/wayback/20220612062505im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Gizmos.DrawLine is dissapearing after returning to editor after Playing the scene 0 Answers
Gizmos icons 0 Answers
Rotating Bezier curves. 0 Answers
How to draw slider thumb on top 0 Answers
Multiple Cars not working 1 Answer