Beispiel #1
0
 void GenerateSpriteMesh()
 {
     spr.scale = scale / 10;
     spr.depth = 0.04f;
     GetComponent <MeshFilter>().mesh = spr.depthMesh(new Vector2(0, 0), new Vector2(texture.width, texture.height));
     GetComponent <MeshRenderer>().material.mainTexture = texture;
 }
Beispiel #2
0
    /// <summary>
    /// Updates the image.
    /// </summary>
    public void UpdateImage()
    {
        if (sMesh.texture != defaultTexture)
        {
            sMesh.texture = defaultTexture;
        }

        // Calculate index based on FPS and our timeScale
        int _index = (int)(Time.timeSinceLevelLoad * m_FPS) % (m_UVTileX * m_UVTileY);

        // split into horizontal and vertical index
        int uIndex = 0;

        //This will create an instant character image switch when the player rotates the player around the player.
        // There used to be a noticable pause in changing the image
        if (m_ForceAnimate == false)
        {
            if (m_PrevIndex == _index)
            {
                return;
            }
        }

        //Are we animating?  If so then update the uIndex
        if (IsAnimating == true)
        {
            uIndex         = _index % m_UVTileX;
            m_ForceAnimate = IsAnimating;
        }

        //If at anypoint our forceAnimate is false, do NOT update the mesh
        if (m_ForceAnimate == false)
        {
            return;
        }

        m_ForceAnimate = false;
        m_PrevIndex    = _index;

        myRenderer.sharedMaterial.mainTexture = defaultTexture;

        myMeshFilter.mesh = null;
        myMeshFilter.mesh = sMesh.depthMesh(new Vector2((uIndex) * defaultTexture.width / 4, (3 - (int)CurDirState) * defaultTexture.height / 4), new Vector2(defaultTexture.width / 4, defaultTexture.height / 4));
    }