exTileMapRenderer.ForceUpdateMesh C# (CSharp) Method

ForceUpdateMesh() public method

public ForceUpdateMesh ( Mesh _mesh ) : void
_mesh Mesh
return void
    public void ForceUpdateMesh( Mesh _mesh )
    {
        // pre check mesh
        if ( _mesh == null )
            return;

        _mesh.Clear();
        updateFlags = UpdateFlags.Index | UpdateFlags.Vertex | UpdateFlags.Color | UpdateFlags.UV;
        UpdateMesh( _mesh );
    }

Usage Example

Ejemplo n.º 1
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public static void Build(this exTileMapRenderer _tileMapRenderer)
    {
        EditorUtility.SetDirty(_tileMapRenderer);

        // NOTE: it is possible user duplicate an GameObject,
        //       if we directly change the mesh, the original one will changed either.
        Mesh newMesh = new Mesh();

        newMesh.hideFlags = HideFlags.DontSave;
        newMesh.Clear();

        // build vertices, normals, uvs and colors.
        _tileMapRenderer.ForceUpdateMesh(newMesh);

        //
        GameObject.DestroyImmediate(_tileMapRenderer.meshFilter.sharedMesh, true);   // delete old mesh (to avoid leaking)
        _tileMapRenderer.meshFilter.sharedMesh = newMesh;
    }