UnityEditor.Handles.CylinderHandleCap C# (CSharp) Method

CylinderHandleCap() public static method

Draw a cylinder handle. Pass this into handle functions.

public static CylinderHandleCap ( int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType ) : void
controlID int The control ID for the handle.
position Vector3 The world-space position of the handle's start point.
rotation UnityEngine.Quaternion The rotation of the handle.
size float The size of the handle in world-space units.
eventType EventType Event type for the handle to act upon. By design it handles EventType.Layout and EventType.Repaint events.
return void
        public static void CylinderHandleCap(int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType)
        {
            if (eventType != EventType.Layout)
            {
                if (eventType == EventType.Repaint)
                {
                    Graphics.DrawMeshNow(s_CylinderMesh, StartCapDraw(position, rotation, size));
                }
            }
            else
            {
                HandleUtility.AddControl(controlID, HandleUtility.DistanceToCircle(position, size));
            }
        }

Usage Example

示例#1
0
        private void ShowPrismaticLimits(ArticulationBody body, ArticulationBody parentBody, Matrix4x4 parentAnchorSpace)
        {
            // if prismatic and unlocked - nothing to visualise
            if (body.linearLockX == ArticulationDofLock.FreeMotion || body.linearLockY == ArticulationDofLock.FreeMotion || body.linearLockZ == ArticulationDofLock.FreeMotion)
            {
                return;
            }

            float dashSize = 5;

            // compute the primary axis of the prismatic
            Vector3           primaryAxis = Vector3.zero;
            ArticulationDrive drive       = body.xDrive;

            if (body.linearLockX == ArticulationDofLock.LimitedMotion)
            {
                primaryAxis = Vector3.right;
                drive       = body.xDrive;
            }
            else if (body.linearLockY == ArticulationDofLock.LimitedMotion)
            {
                primaryAxis = Vector3.up;
                drive       = body.yDrive;
            }
            else if (body.linearLockZ == ArticulationDofLock.LimitedMotion)
            {
                primaryAxis = Vector3.forward;
                drive       = body.zDrive;
            }

            // now show the valid movement along the axis as well as limits
            using (new Handles.DrawingScope(parentAnchorSpace))
            {
                Vector3 lowerPoint = primaryAxis * drive.lowerLimit;
                Vector3 upperPoint = primaryAxis * drive.upperLimit;

                Quaternion orientation = Quaternion.LookRotation(primaryAxis);

                Handles.color = Color.red;
                Handles.CylinderHandleCap(0, lowerPoint, orientation, CapScale, EventType.Repaint);

                Handles.color = Color.green;
                Handles.CylinderHandleCap(0, upperPoint, orientation, CapScale, EventType.Repaint);

                Handles.color = Color.white;
                Handles.DrawDottedLine(lowerPoint, upperPoint, dashSize);
            }
        }
All Usage Examples Of UnityEditor.Handles::CylinderHandleCap