private void AssignMeshAndMaterial(int textureArchive) { // Get mesh filter if (meshFilter == null) { meshFilter = GetComponent <MeshFilter>(); } // Vertices for a 1x1 unit quad // This is scaled to correct size depending on facing and orientation float hx = 0.5f, hy = 0.5f; Vector3[] vertices = new Vector3[4]; vertices[0] = new Vector3(hx, hy, 0); vertices[1] = new Vector3(-hx, hy, 0); vertices[2] = new Vector3(hx, -hy, 0); vertices[3] = new Vector3(-hx, -hy, 0); // Indices int[] indices = new int[6] { 0, 1, 2, 3, 2, 1, }; // Normals Vector3 normal = Vector3.Normalize(Vector3.up + Vector3.forward); Vector3[] normals = new Vector3[4]; normals[0] = normal; normals[1] = normal; normals[2] = normal; normals[3] = normal; // Create mesh Mesh mesh = new Mesh(); mesh.name = string.Format("MobilePersonMesh"); mesh.vertices = vertices; mesh.triangles = indices; mesh.normals = normals; // Assign mesh meshFilter.sharedMesh = mesh; // Seek textures from mods TextureReplacement.SetMobileBillboardImportedTextures(textureArchive, GetComponent <MeshFilter>(), ref importedTextures); // Create material Material material = importedTextures.HasImportedTextures ? MaterialReader.CreateStandardMaterial(MaterialReader.CustomBlendMode.Cutout) : DaggerfallUnity.Instance.MaterialReader.GetMaterialAtlas( textureArchive, 0, 4, 1024, out atlasRects, out atlasIndices, 4, true, 0, false, true); // Set new person material GetComponent <MeshRenderer>().sharedMaterial = material; }