示例#1
0
        /// <summary>
        /// Draws a "Sphere" gizmo
        /// </summary>
        /// <param name="component">The target component</param>
        /// <param name="alpha">The base opacity</param>
        private static void DrawSphere(AuraVolume component, float alpha)
        {
            float thickness = CustomGizmo.pixelWidth;
            Color color     = CustomGizmo.color;

            color.a *= alpha;
            CustomGizmo.DrawSphere(component.transform.localToWorldMatrix, color, CustomGizmo.pixelWidth);

            float x = 1.0f - component.volumeShape.fading.distanceSphereFade;

            CustomGizmo.DrawLineSegment(Vector3.up * 0.5f, Vector3.up * x * 0.5f, component.transform.localToWorldMatrix, color, thickness);
            CustomGizmo.DrawLineSegment(Vector3.down * 0.5f, Vector3.down * x * 0.5f, component.transform.localToWorldMatrix, color, thickness);
            CustomGizmo.DrawLineSegment(Vector3.left * 0.5f, Vector3.left * x * 0.5f, component.transform.localToWorldMatrix, color, thickness);
            CustomGizmo.DrawLineSegment(Vector3.right * 0.5f, Vector3.right * x * 0.5f, component.transform.localToWorldMatrix, color, thickness);
            CustomGizmo.DrawLineSegment(Vector3.back * 0.5f, Vector3.back * x * 0.5f, component.transform.localToWorldMatrix, color, thickness);
            CustomGizmo.DrawLineSegment(Vector3.forward * 0.5f, Vector3.forward * x * 0.5f, component.transform.localToWorldMatrix, color, thickness);

            CustomGizmo.DrawSphere(component.transform.localToWorldMatrix, Vector3.zero, Quaternion.identity, Vector3.one * x, color, thickness);
        }
示例#2
0
        /// <summary>
        /// Draws the gizmo
        /// </summary>
        /// <param name="component">The target component</param>
        /// <param name="opacity">The gizmo opacity</param>
        private static void DrawGizmo(AuraLight component, float opacity)
        {
            Color color = CustomGizmo.color;

            color.a = CustomGizmo.color.a * opacity;

            switch (component.Type)
            {
            case LightType.Directional:
            {
                float       size       = HandleUtility.GetHandleSize(component.transform.position);
                const int   stepAmount = 8;
                const float width      = 1.0f;
                const float length     = 3.0f;
                CustomGizmo.DrawCircle(Matrix4x4.TRS(component.transform.position, component.transform.rotation * Quaternion.AngleAxis(90, Vector3.right), Vector3.one * size * width), color, CustomGizmo.pixelWidth);
                for (int i = 0; i < stepAmount; ++i)
                {
                    float   ratio = (float)i / (float)stepAmount * 2.0f * Mathf.PI;
                    Vector3 localStartPosition       = new Vector3(Mathf.Sin(ratio), Mathf.Cos(ratio), 0) * size * width * 0.5f;
                    Vector3 transformedStartPosition = component.transform.localToWorldMatrix.MultiplyPoint(localStartPosition);
                    CustomGizmo.DrawLineSegment(transformedStartPosition, transformedStartPosition + component.transform.forward * size * length, color, CustomGizmo.pixelWidth);
                }
            }
            break;

            case LightType.Spot:
            {
                float angleToWidth = Mathf.Tan(component.GetComponent <Light>().spotAngle *Mathf.Deg2Rad * 0.5f) * 2.0f * component.GetComponent <Light>().range;
                CustomGizmo.DrawCone(Matrix4x4.TRS(component.transform.position, component.transform.rotation, new Vector3(angleToWidth, angleToWidth, component.GetComponent <Light>().range)), color, CustomGizmo.pixelWidth);
            }
            break;

            case LightType.Point:
            {
                CustomGizmo.DrawSphere(Matrix4x4.TRS(component.transform.position, component.transform.rotation, Vector3.one * component.GetComponent <Light>().range * 2.0f), color, CustomGizmo.pixelWidth);
            }
            break;
            }
        }