コード例 #1
0
 private void OnDrawGizmos()
 {
     if (!SpringManager.onlyShowSelectedBones)
     {
         HandlesUtil.DrawTransform(transform, DrawScale);
     }
 }
コード例 #2
0
        public void DrawGizmos()
        {
            var collisionCount = collisions.Count;

            for (int collisionIndex = 0; collisionIndex < collisionCount; collisionIndex++)
            {
                var collision = collisions[collisionIndex];
                Handles.color = (collision.collisionStatus == SpringBone.CollisionStatus.HeadIsEmbedded) ?
                                Color.red : Color.yellow;
                Handles.DrawWireDisc(collision.position, collision.normal, collision.radius);
                HandlesUtil.DrawArrow(
                    collision.position, collision.position + collision.normal * 0.1f, Handles.color, 0.1f);
            }
        }
コード例 #3
0
        public void DrawGizmos(Color color)
        {
            const int PointCount = 4;

            if (localGizmoPoints == null ||
                worldGizmoPoints == null ||
                localGizmoPoints.Length < PointCount ||
                worldGizmoPoints.Length < PointCount)
            {
                localGizmoPoints = new Vector3[PointCount];
                worldGizmoPoints = new Vector3[PointCount];
            }

            var halfWidth  = 0.5f * width;
            var halfHeight = 0.5f * height;

            localGizmoPoints[0] = new Vector3(-halfWidth, -halfHeight, 0f);
            localGizmoPoints[1] = new Vector3(halfWidth, -halfHeight, 0f);
            localGizmoPoints[2] = new Vector3(halfWidth, halfHeight, 0f);
            localGizmoPoints[3] = new Vector3(-halfWidth, halfHeight, 0f);

            for (int pointIndex = 0; pointIndex < PointCount; pointIndex++)
            {
                worldGizmoPoints[pointIndex] = transform.TransformPoint(localGizmoPoints[pointIndex]);
            }

            UnityEditor.Handles.color = color;
            for (int pointIndex = 0; pointIndex < PointCount; pointIndex++)
            {
                var endPointIndex = (pointIndex + 1) % PointCount;
                UnityEditor.Handles.DrawLine(worldGizmoPoints[pointIndex], worldGizmoPoints[endPointIndex]);
                UnityEditor.Handles.DrawLine(worldGizmoPoints[pointIndex], worldGizmoPoints[pointIndex] - 0.15f * transform.forward);
            }

            HandlesUtil.DrawArrow(transform.position, transform.position + transform.forward * 0.1f, color, 0.1f);

            if (colliderDebug != null)
            {
                colliderDebug.DrawGizmos();
            }
        }
コード例 #4
0
 private void OnDrawGizmosSelected()
 {
     HandlesUtil.DrawTransform(transform, DrawScale);
 }
コード例 #5
0
ファイル: SpringBone.cs プロジェクト: kooa77/UnityActions
        private void OnDrawGizmosSelected()
        {
            // Don't draw us if we're a child of the selection because it's too much visual noise
            if (!UnityEditor.Selection.gameObjects.Contains(gameObject))
            {
                return;
            }

            var drawScale = GetDrawScale();

            if (pivotNode != transform.parent)
            {
                HandlesUtil.DrawTransform(pivotNode, drawScale);
            }
            DrawAngleLimits(drawScale);

            var drawColor = GetDrawColor(true);

            DrawSpringBone(drawColor);

            var ColliderColor = new Color(0.8f, 0.8f, 1f);

            if (sphereColliders != null)
            {
                foreach (var collider in sphereColliders.Where(collider => collider != null))
                {
                    collider.DrawGizmos(ColliderColor);
                }
            }

            if (capsuleColliders != null)
            {
                foreach (var collider in capsuleColliders.Where(collider => collider != null))
                {
                    collider.DrawGizmos(ColliderColor);
                }
            }

            if (panelColliders != null)
            {
                foreach (var collider in panelColliders.Where(collider => collider != null))
                {
                    collider.DrawGizmos(ColliderColor);
                }
            }

            if (lengthLimitTargets != null &&
                lengthLimitTargets.Length > 0)
            {
                DrawLinesToLimitTargets();
                for (int targetIndex = 0; targetIndex < lengthLimitTargets.Length; targetIndex++)
                {
                    var target = lengthLimitTargets[targetIndex];
                    if (target != null)
                    {
                        var targetSpringBone = target.GetComponent <SpringBone>();
                        if (targetSpringBone != null)
                        {
                            var LimitTargetColor = new Color(0.5f, 1f, 0.5f);
                            Gizmos.color = LimitTargetColor;
                            if (SpringManager.showBoneSpheres)
                            {
                                Gizmos.DrawWireSphere(target.position, targetSpringBone.radius);
                            }
                        }
                    }
                }
            }
        }