void LateUpdate()
    {
        //float screenWidth = Screen.width;
        float screenHeight = Screen.height;
        float deltaTime    = Time.deltaTime;

        m_EulerRotation.x += deltaTime * 90f;
        m_EulerRotation.x  = Mathf.Repeat(m_EulerRotation.x, 360f);
        m_EulerRotation.z  = m_EulerRotation.y = m_EulerRotation.x;
        m_RotationY        = Mathf.Repeat(m_RotationY + (deltaTime * 45f), 360f);

        Vector3    origin = Vector3.zero;
        Vector3    position;
        Quaternion objectRotation = Quaternion.Euler(m_EulerRotation);

        Quaternion rotation = Quaternion.Euler(0f, m_RotationY, 0f);

        IMDraw.Axis3D(Vector3.zero, Quaternion.identity, 100f, 1f);

        IMDraw.Grid3D(Vector3.zero, Quaternion.identity, 5f, 5f, 10, 10, new Color(1f, 1f, 1f, 0.5f));

        position = origin + (rotation * new Vector3(-2f, 2f, 0f));
        IMDraw.Quad3D(position, objectRotation, 1f, 1f, m_TestAxis, ToColor(m_ColorQuad, 0.25f));
        IMDraw.Grid3D(position, objectRotation, 1f, 1f, 1, 1, m_TestAxis, m_ColorQuad);
        IMDraw.LabelShadowed(position, m_ColorQuad, LabelPivot.MIDDLE_CENTER, LabelAlignment.CENTER, "QUAD");

        position = origin + (rotation * new Vector3(0f, 2f, 0f));
        IMDraw.Box3D(position, objectRotation, new Vector3(1f, 1f, 1f), ToColor(m_ColorBox, 0.25f));
        IMDraw.WireBox3D(position, objectRotation, new Vector3(1f, 1f, 1f), m_ColorBox);
        IMDraw.LabelShadowed(position, m_ColorBox, LabelPivot.MIDDLE_CENTER, LabelAlignment.CENTER, "BOX");

        position = origin + (rotation * new Vector3(2f, 2f, 0f));
        float pyramidHeight = 1f, pyramidWidth = 0.5f;

        IMDraw.Pyramid3D(position, objectRotation, pyramidHeight, pyramidWidth, m_TestAxis, ToColor(m_ColorPyramid, 0.25f));
        IMDraw.WirePyramid3D(position, objectRotation, pyramidHeight, pyramidWidth, m_TestAxis, m_ColorPyramid);
        IMDraw.LabelShadowed(position, m_ColorPyramid, LabelPivot.MIDDLE_CENTER, LabelAlignment.CENTER, "PYRAMID");

        position = origin + (rotation * new Vector3(0f, 2f, 2f));
        float rhombusHeight = 2f, rhombusWidth = 0.75f;

        IMDraw.Rhombus3D(position, objectRotation, rhombusHeight, rhombusWidth, m_TestAxis, ToColor(m_ColorRhombus, 0.25f));
        IMDraw.WireRhombus3D(position, objectRotation, rhombusHeight, rhombusWidth, m_TestAxis, m_ColorRhombus);
        IMDraw.LabelShadowed(position, m_ColorRhombus, LabelPivot.MIDDLE_CENTER, LabelAlignment.CENTER, "RHOMBUS");

        position = origin + (rotation * new Vector3(0f, 2f, -2f));
        IMDraw.Disc3D(position, objectRotation, 0.5f, m_TestAxis, ToColor(m_ColorDisc, 0.25f));
        IMDraw.WireDisc3D(position, objectRotation, 0.5f, m_TestAxis, m_ColorDisc);
        IMDraw.LabelShadowed(position, m_ColorDisc, LabelPivot.MIDDLE_CENTER, LabelAlignment.CENTER, "DISC");


        position = origin + (rotation * new Vector3(0f, -2f, 0f));
        IMDraw.WireSphere3D(position, objectRotation, 0.5f, m_ColorSphere);
        IMDraw.Sphere3D(position, objectRotation, 0.5f, ToColor(m_ColorSphere, 0.25f));
        IMDraw.LabelShadowed(position, m_ColorSphere, LabelPivot.MIDDLE_CENTER, LabelAlignment.CENTER, "SPHERE");

        position = origin + (rotation * new Vector3(2f, -2f, 0f));
        IMDraw.Cylinder3D(position, objectRotation, 2f, 0.25f, IMDrawAxis.X, ToColor(m_ColorCylinder, 0.25f));
        IMDraw.WireCylinder3D(position, objectRotation, 2f, 0.25f, IMDrawAxis.X, ToColor(m_ColorCylinder, 0.25f));
        IMDraw.LabelShadowed(position, m_ColorCylinder, LabelPivot.MIDDLE_CENTER, LabelAlignment.CENTER, "CYLINDER");

        position = origin + (rotation * new Vector3(-2f, -2f, 0f));
        IMDraw.Capsule3D(position, objectRotation, 2f, 0.25f, IMDrawAxis.Y, ToColor(m_ColorCapsule, 0.25f));
        IMDraw.WireCapsule3D(position, objectRotation, 2f, 0.25f, IMDrawAxis.Y, m_ColorCapsule);
        IMDraw.LabelShadowed(position, m_ColorCapsule, LabelPivot.MIDDLE_CENTER, LabelAlignment.CENTER, "CAPSULE");

        position = origin + (rotation * new Vector3(0f, -2f, 2f));
        Vector3 ellipsoidSize = new Vector3(2f, 1f, 1f);

        IMDraw.Ellipsoid3D(position, objectRotation, ellipsoidSize, ToColor(m_ColorEllipsoid, 0.25f));
        IMDraw.WireEllipsoid3D(position, objectRotation, ellipsoidSize, m_ColorEllipsoid);
        IMDraw.LabelShadowed(position, m_ColorEllipsoid, LabelPivot.MIDDLE_CENTER, LabelAlignment.CENTER, "ELLIPSOID");

        position = origin + (rotation * new Vector3(0f, -2f, -2f));
        IMDraw.Cone3D(position, objectRotation, 1f, 0.5f, m_TestAxis, ToColor(m_ColorCone, 0.25f));
        IMDraw.WireCone3D(position, objectRotation, 1f, 0.5f, m_TestAxis, m_ColorCone);
        IMDraw.LabelShadowed(position, m_ColorCone, LabelPivot.MIDDLE_CENTER, LabelAlignment.CENTER, "CONE");

        if (m_TestParticleSystemRenderer != null)
        {
            IMDraw.Bounds(m_TestParticleSystemRenderer.bounds, Color.green);
        }

        IMDraw.LabelShadowed(Screen.width / 2f, 10f, Color.white, LabelPivot.UPPER_CENTER, LabelAlignment.CENTER, "EXAMPLE SCENE 1: PRIMITIVES & LABELS");

        IMDraw.LabelShadowed(10f, screenHeight - 10f, Color.white, LabelPivot.LOWER_LEFT, LabelAlignment.LEFT, m_Controls);
    }
Example #2
0
    void LateUpdate()
    {
        Vector3 position = m_Transform.position;

        float       labelX      = 10f;
        float       labelY      = 0f;
        const float lineSpacing = 14f;

        IMDraw.LabelShadowed(position, 0f, labelY, m_NameColor, LabelPivot.MIDDLE_CENTER, LabelAlignment.CENTER, "■");

        if (m_ShowName)
        {
            // Note: Accessing the name on a gameobject generates garbage...
            IMDraw.LabelShadowed(position, labelX, labelY, m_NameColor, LabelPivot.MIDDLE_LEFT, LabelAlignment.LEFT, name);
            labelY += lineSpacing;
        }

        if (m_ShowTag)
        {
            // Note: Accessing the tag on a gameobject generates garbage...
            IMDraw.LabelShadowed(position, labelX, labelY, m_TagColor, LabelPivot.MIDDLE_LEFT, LabelAlignment.LEFT, tag);
            labelY += lineSpacing;
        }

        if (m_ShowPosition)
        {
            position.x = (float)Math.Round(position.x, POSITION_ROUNDING_DECIMALS);
            position.y = (float)Math.Round(position.y, POSITION_ROUNDING_DECIMALS);
            position.z = (float)Math.Round(position.z, POSITION_ROUNDING_DECIMALS);

            if (position != m_GameObjectPosition)             // Only update the position string when the position has changed, to reduce GC pressure
            {
                m_GameObjectPosition = position;

                m_StringBuilder.Length = 0;
                m_StringBuilder.Append("xyz : ");
                m_StringBuilder.Append(position.x);
                m_StringBuilder.Append(", ");
                m_StringBuilder.Append(position.y);
                m_StringBuilder.Append(", ");
                m_StringBuilder.Append(position.z);
                m_PositionString = m_StringBuilder.ToString();
            }

            IMDraw.LabelShadowed(position, labelX, labelY, m_TagColor, LabelPivot.MIDDLE_LEFT, LabelAlignment.LEFT, m_PositionString);
            labelY += lineSpacing;
        }

        if (m_ShowEulerRotation)
        {
            Vector3 eulerRotation = m_Transform.rotation.eulerAngles;
            eulerRotation.x = (float)Math.Round(eulerRotation.x, ROTATION_ROUNDING_DECIMALS);
            eulerRotation.y = (float)Math.Round(eulerRotation.y, ROTATION_ROUNDING_DECIMALS);
            eulerRotation.z = (float)Math.Round(eulerRotation.z, ROTATION_ROUNDING_DECIMALS);

            if (eulerRotation != m_GameObjectEulerRotation)
            {
                m_GameObjectEulerRotation = eulerRotation;

                m_StringBuilder.Length = 0;
                m_StringBuilder.Append("deg : ");
                m_StringBuilder.Append(eulerRotation.x);
                m_StringBuilder.Append(", ");
                m_StringBuilder.Append(eulerRotation.y);
                m_StringBuilder.Append(", ");
                m_StringBuilder.Append(eulerRotation.z);
                m_RotationString = m_StringBuilder.ToString();
            }

            IMDraw.LabelShadowed(position, labelX, labelY, m_TagColor, LabelPivot.MIDDLE_LEFT, LabelAlignment.LEFT, m_RotationString);
            labelY += lineSpacing;
        }

        if (m_ShowRendererBounds && m_Renderers != null && m_Renderers.Count > 0)
        {
            for (int i = 0; i < m_Renderers.Count; ++i)
            {
                if (m_Renderers[i] != null)
                {
                    IMDraw.Bounds(m_Renderers[i], m_BoundsColor);
                }
            }
        }

        if (m_ShowWireframeColliders && m_Colliders != null && m_Colliders.Count > 0)
        {
            for (int i = 0; i < m_Colliders.Count; ++i)
            {
                if (m_Colliders[i] != null)
                {
                    IMDraw.Collider(m_Colliders[i], m_ColliderColor, m_ColliderScaleOffset, m_ShowSolidColliders);
                }
            }
        }
    }