Esempio n. 1
0
        /// <summary>
        /// Draws a "Global" gizmo
        /// </summary>
        /// <param name="component">The target component</param>
        /// <param name="alpha">The base opacity</param>
        private static void DrawGlobal(AuraVolume component, float alpha)
        {
            Color color = CustomGizmo.color;

            color.a = CustomGizmo.color.a * alpha;
            const int   circlesAmount = 10;
            const float maxWidth      = 5.0f;

            for (int i = 1; i <= circlesAmount; ++i)
            {
                float ratio       = (float)i / (float)circlesAmount;
                float curvedRatio = Mathf.Pow(ratio, 2.5f);
                CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * maxWidth * curvedRatio), color, CustomGizmo.pixelWidth);
            }
        }
Esempio n. 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;
            }
        }