Exemplo n.º 1
0
 private void Dispose(IMDrawTextMesh textMesh)
 {
     textMesh.Hide();
     m_TextMeshList.Remove(textMesh.m_ListNode);
     m_TextMeshPool.Push(textMesh);
     //Debug.Log("Text mesh disposed");
 }
Exemplo n.º 2
0
 private static void OnScriptsReloaded()
 {
     if (Application.isPlaying)
     {
         // Destroy all IMDrawTextMesh in the scene. When the scripts are reloaded,
         // the IMDrawTextMeshComponent loses its references to existing IMDrawTextMesh objects in the scene and must reinitialise.
         // This basically destroys all orphaned objects.
         IMDrawTextMesh.DestroyAllInstances();
     }
 }
Exemplo n.º 3
0
    public static IMDrawTextMesh Create(IMDrawTextMeshComponent component)
    {
        GameObject gameObj = new GameObject();

                #if UNITY_EDITOR
        gameObj.name      = "IMDrawTextMesh";
        gameObj.hideFlags = HideFlags.HideInHierarchy;
                #endif // UNITY_EDITOR
        Transform tf = gameObj.transform;

        MeshRenderer   meshRenderer = gameObj.AddComponent <MeshRenderer>();
        TextMesh       textMesh     = gameObj.AddComponent <TextMesh>();
        IMDrawTextMesh obj          = gameObj.AddComponent <IMDrawTextMesh>();

        obj.m_Material = new Material(component.IMDrawCamera.MaterialTextMesh);

        meshRenderer.shadowCastingMode    = ShadowCastingMode.Off;
        meshRenderer.receiveShadows       = false;
        meshRenderer.sharedMaterial       = obj.m_Material;
        meshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off;

                #if UNITY_5_4_OR_NEWER
        meshRenderer.lightProbeUsage = LightProbeUsage.Off;

                #if UNITY_5_5_OR_NEWER
        meshRenderer.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion;
                #else
        meshRenderer.motionVectors = false;
                #endif // UNITY_5_5_OR_NEWER
                #else
        meshRenderer.useLightProbes = false;
                #endif

        textMesh.font     = component.m_Font;
        textMesh.richText = true;

        obj.m_RootGameObject = gameObj;
        obj.m_RootTransform  = tf;
        obj.m_MeshRenderer   = meshRenderer;
        obj.m_TextMesh       = textMesh;
        obj.m_Option         = IMDrawTextMeshOption.FACE_CAMERA | IMDrawTextMeshOption.DISTANCE_SCALE;
        obj.m_ListNode       = new LinkedListNode <IMDrawTextMesh>(obj);
        obj.m_Visible        = true;

        return(obj);
    }
Exemplo n.º 4
0
    private IMDrawTextMesh Create()
    {
        IMDrawTextMesh textMesh;

        if (m_TextMeshPool.Count > 0)
        {
            textMesh = m_TextMeshPool.Pop();
            textMesh.m_RootTransform.SetParent(null, false);
        }
        else
        {
            textMesh = IMDrawTextMesh.Create(this);
        }

        m_TextMeshList.AddLast(textMesh.m_ListNode);

        textMesh.SetZTest(IMDrawManager.s_ZTest);

        return(textMesh);
    }
Exemplo n.º 5
0
    public void DrawTextMesh(string text, Color color, Vector3 position, float scaleX, float scaleY, TextAlignment align, TextAnchor anchor, IMDrawTextMeshOption options, float duration = 0f)
    {
        IMDrawTextMesh textMesh = Create();

        textMesh.m_TextMesh.text  = text;
        textMesh.m_TextMesh.color = color;
        //textMesh.SetFont(m_Font);
        textMesh.m_TextMesh.fontSize           = m_FontSize;
        textMesh.m_TextMesh.alignment          = align;
        textMesh.m_TextMesh.anchor             = anchor;
        textMesh.m_RootTransform.localPosition = position;
        textMesh.m_Color  = color;
        textMesh.m_Scale  = m_FontSizeAffectsScale ? new Vector2(scaleX, scaleY) : new Vector2(scaleX / (float)m_FontSize, scaleY / (float)m_FontSize);
        textMesh.m_Option = options;
        textMesh.m_T      = duration;

        if ((options & IMDrawTextMeshOption.DISTANCE_SCALE) == 0)
        {
            textMesh.m_RootTransform.localScale = new Vector3(textMesh.m_Scale.x, textMesh.m_Scale.y, 1f);             // If no dynamic scaling is used, set the transform scale right away
        }
    }