public void UseTIX(TIX tix)
        {
            var tex = LibLSDUnity.GetTextureFromTIX(tix);

            LBDDiffuse.SetTexture(_mainTex, tex);
            LBDAlpha.SetTexture(_mainTex, tex);
        }
        private FastMesh createTileMesh(LBDTile tile, TMD tilesTmd, Dictionary <TMDObject, FastMesh> tileCache)
        {
            TMDObject tileObj = tilesTmd.ObjectTable[tile.TileType];

            if (tileCache.ContainsKey(tileObj))
            {
                return(tileCache[tileObj]);
            }

            Mesh     m  = LibLSDUnity.MeshFromTMDObject(tileObj);
            FastMesh fm = new FastMesh(m, new[] { LBDDiffuse, LBDAlpha });

            tileCache[tileObj] = fm;
            return(fm);
        }
        // create a single LBD tile GameObject (not including extra tiles)
        private GameObject createSingleLBDTile(LBDTile tile, int x, int y, TMD tilesTmd,
                                               List <CombineInstance> meshesCreated, Dictionary <TMDObject, Mesh> cache)
        {
            // rotate the tile based on its direction
            Quaternion tileRot = Quaternion.identity;

            switch (tile.TileDirection)
            {
            case LBDTile.TileDirections.Deg90:
            {
                tileRot = Quaternion.AngleAxis(90, Vector3.up);
                break;
            }

            case LBDTile.TileDirections.Deg180:
            {
                tileRot = Quaternion.AngleAxis(180, Vector3.up);
                break;
            }

            case LBDTile.TileDirections.Deg270:
            {
                tileRot = Quaternion.AngleAxis(270, Vector3.up);
                break;
            }
            }

            // create the GameObject and add/setup necessary components
            GameObject   lbdTile = LBDTilePool.Summon(new Vector3(x, -tile.TileHeight, y), tileRot);
            MeshFilter   mf      = lbdTile.GetComponent <MeshFilter>();
            MeshRenderer mr      = lbdTile.GetComponent <MeshRenderer>();
            TMDObject    tileObj = tilesTmd.ObjectTable[tile.TileType];
            Mesh         tileMesh;

            if (cache.ContainsKey(tileObj))
            {
                tileMesh = cache[tileObj];
            }
            else
            {
                tileMesh       = LibLSDUnity.MeshFromTMDObject(tileObj);
                cache[tileObj] = tileMesh;
            }
            mf.sharedMesh = tileMesh;

            // the renderer needs to use virtual PSX Vram as its materials
            mr.sharedMaterials = new[] { LBDDiffuse, LBDAlpha };

            // set the tile's height
            lbdTile.transform.position = new Vector3(x, -tile.TileHeight, y);

            // make a CombineInstance for combining all tiles into one mesh later on
            var             localToWorldMatrix = lbdTile.transform.localToWorldMatrix;
            CombineInstance combine            = new CombineInstance()
            {
                mesh         = tileMesh,
                transform    = localToWorldMatrix,
                subMeshIndex = 0
            };

            meshesCreated.Add(combine);

            // if tile has transparent part, do the same for the transparent mesh
            if (tileMesh.subMeshCount > 1)
            {
                CombineInstance combineTrans = new CombineInstance()
                {
                    mesh         = tileMesh,
                    transform    = localToWorldMatrix,
                    subMeshIndex = 1
                };
                meshesCreated.Add(combineTrans);
            }

            return(lbdTile);
        }