Exemplo n.º 1
0
        public void ForceUpdateCachedVertData()
        {
            m_animation_manager.PopulateDefaultMeshData(true);

            // Force update cached values
            UIVertex uiVert;

            for (int idx = 0; idx < m_animation_manager.MeshVerts.Length; idx++)
            {
                uiVert             = m_cachedVerts[idx];
                uiVert.position    = m_animation_manager.MeshVerts[idx];
                m_cachedVerts[idx] = uiVert;
            }
        }
Exemplo n.º 2
0
        protected override void OnFillVBO(List <UIVertex> vbo)
#endif
        {
            if (font == null)
            {
                m_textFxAnimDrawCall = false;
                return;
            }


            if (!m_textFxAnimDrawCall || m_cachedVerts == null)
            {
#if UGUI_VERSION_3
                if (m_cachedVerts == null)
                {
                    m_cachedVerts = new List <UIVertex>();
                }

                base.OnPopulateMesh(vHelper);
#else
                base.OnFillVBO(vbo);
#endif



#if UGUI_VERSION_3
                int numLetterMeshes = vHelper.currentVertCount / 4;

                // Add in any effect mesh additions
                AddEffectMeshes(vHelper);


                // Update UIVertex cache
                m_cachedVerts.Clear();

                UIVertex new_vert = new UIVertex();
                for (int idx = 0; idx < vHelper.currentVertCount; idx++)
                {
                    vHelper.PopulateUIVertex(ref new_vert, idx);

                    m_cachedVerts.Add(new_vert);
                }

                // Update current mesh state values
                m_currentMeshVerts = m_cachedVerts.GetRange(0, m_cachedVerts.Count);
#else
                int numLetterMeshes = vbo.Count / 4;

                // Update caches
                m_cachedVerts = vbo.GetRange(0, vbo.Count);

                // Update current mesh state values
                m_currentMeshVerts = vbo.GetRange(0, vbo.Count);
#endif


                // Call to update animation letter setups
                m_animation_manager.UpdateText(text, new UGUITextDataHandler(m_cachedVerts, numLetterMeshes), white_space_meshes: true);


                if (Application.isPlaying ||
                    m_animation_manager.Playing                                         // Animation is playing, so will now need to render this new mesh in the current animated state
#if UNITY_EDITOR
                    || TextFxAnimationManager.ExitingPlayMode                           // To stop text being auto rendered in to default position when exiting play mode in editor.
#endif
                    )
                {
                    // The verts need to be set to their current animated states
                    // So recall OnFillVBO, getting it to populate with whatever available animate mesh data for this frame
                    m_textFxAnimDrawCall = true;

                    // Update animated mesh values to latest
                    m_animation_manager.UpdateMesh(true, true, delta_time: 0);

#if UGUI_VERSION_3
                    OnPopulateMesh(vHelper);
#else
                    vbo.Clear();

                    OnFillVBO(vbo);
#endif

                    return;
                }
                else
                {
                    m_animation_manager.PopulateDefaultMeshData(true);
                }
            }
            else
            {
                // TextFx render call. Use cached text mesh data
                UIVertex new_vert = new UIVertex();

#if UGUI_VERSION_3
                vHelper.Clear();
                if (m_currentMeshVerts == null)
                {
                    m_currentMeshVerts = new List <UIVertex>();
                }
                else
                {
                    m_currentMeshVerts.Clear();
                }

                // Add each cached vert into the VBO buffer. Verts seem to need to be added one by one using Add(), can't just copy the list over
                for (int idx = 0; idx < m_cachedVerts.Count; idx += 4)
                {
                    vHelper.AddUIVertexQuad(new UIVertex[] { m_cachedVerts[idx], m_cachedVerts[idx + 1], m_cachedVerts[idx + 2], m_cachedVerts[idx + 3] });

                    m_currentMeshVerts.Add(m_cachedVerts[idx]);
                    m_currentMeshVerts.Add(m_cachedVerts[idx + 1]);
                    m_currentMeshVerts.Add(m_cachedVerts[idx + 2]);
                    m_currentMeshVerts.Add(m_cachedVerts[idx + 3]);

                    if (m_animation_manager.MeshVerts != null && idx < m_animation_manager.MeshVerts.Length)
                    {
                        for (int qidx = 0; qidx < 4; qidx++)
                        {
                            vHelper.PopulateUIVertex(ref new_vert, idx + qidx);
                            new_vert.position = m_animation_manager.MeshVerts[idx + qidx];
                            new_vert.color    = m_animation_manager.MeshColours[idx + qidx];
                            vHelper.SetUIVertex(new_vert, idx + qidx);

                            m_currentMeshVerts[idx + qidx] = new_vert;
                        }
                    }
                }
#else
                // Add each cached vert into the VBO buffer. Verts seem to need to be added one by one using Add(), can't just copy the list over
                for (int idx = 0; idx < m_cachedVerts.Count; idx++)
                {
                    vbo.Add(m_cachedVerts[idx]);

                    if (m_animation_manager.MeshVerts != null && idx < m_animation_manager.MeshVerts.Length)
                    {
                        new_vert           = vbo[vbo.Count - 1];
                        new_vert.position  = m_animation_manager.MeshVerts[idx];
                        new_vert.color     = m_animation_manager.MeshColours[idx];
                        vbo[vbo.Count - 1] = new_vert;
                    }
                }

                // Update current mesh state values
                m_currentMeshVerts = vbo.GetRange(0, vbo.Count);
#endif

#if UNITY_EDITOR
                // Set object dirty to trigger sceneview redraw/update. Calling SceneView.RepaintAll() doesn't work for some reason.
                EditorUtility.SetDirty(GameObject);
#endif
            }

            m_textFxAnimDrawCall = false;

            if (OnMeshUpdateCall != null)
            {
                OnMeshUpdateCall();
            }
        }
 public void ForceUpdateCachedVertData()
 {
     m_animation_manager.PopulateDefaultMeshData(true);
 }