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

            color.a *= alpha;
            CustomGizmo.DrawCone(component.transform.localToWorldMatrix, color, thickness);

            float z  = 1.0f - component.volumeShape.fading.distanceConeFade;
            float xy = Mathf.Lerp(0, 1.0f - component.volumeShape.fading.angularConeFade, z);

            CustomGizmo.DrawLineSegment(new Vector3(0.0f, 0.5f, 1), new Vector3(0, xy * 0.5f, z), component.transform.localToWorldMatrix, color, thickness);
            CustomGizmo.DrawLineSegment(new Vector3(0.0f, -0.5f, 1), new Vector3(0, -xy * 0.5f, z), component.transform.localToWorldMatrix, color, thickness);
            CustomGizmo.DrawLineSegment(new Vector3(0.5f, 0.0f, 1), new Vector3(xy * 0.5f, 0.0f, z), component.transform.localToWorldMatrix, color, thickness);
            CustomGizmo.DrawLineSegment(new Vector3(-0.5f, 0.0f, 1), new Vector3(-xy * 0.5f, 0.0f, z), component.transform.localToWorldMatrix, color, thickness);

            CustomGizmo.DrawCone(component.transform.localToWorldMatrix, Vector3.zero, Quaternion.identity, new Vector3(xy, xy, z), 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;
            }
        }