public static void meshToTables(Mesh m, SkinnedMeshRenderer ms, out List <Vector3> t_v, out List <Vector3> t_n, out List <Vector2> t_uv, out List <Vector3Int> t_t, out List <int> t_sub, out List <Material> t_materials) { List <Material> materials = new List <Material>(); ms.GetMaterials(materials); List <Vector3> v = new List <Vector3>(); List <Vector3> n = new List <Vector3>(); List <Vector2> uv = new List <Vector2>(); List <Vector3Int> t = new List <Vector3Int>(); m.GetVertices(v); m.GetNormals(n); m.GetUVs(0, uv); var t_tmp = new List <int>(m.triangles); for (int i = 0; i < t_tmp.Count / 3; ++i) { t.Add(new Vector3Int(t_tmp[i * 3 + 0], t_tmp[i * 3 + 1], t_tmp[i * 3 + 2])); } List <int> sub = getSubTable(m); t_v = v; t_n = n; t_uv = uv; t_t = t; t_sub = sub; t_materials = materials; }
public void Start() { if (meshRenderer == null) { meshRenderer = GetComponent <SkinnedMeshRenderer>(); if (meshRenderer == null) { meshRenderer = GetComponentInChildren <SkinnedMeshRenderer>(); } } List <Material> materials = new List <Material>(); meshRenderer.GetMaterials(materials); if (rightEyeMaterialSlot < materials.Count) { materialRightEye = materials[rightEyeMaterialSlot]; } else { Debug.LogWarning("Right eye material index invalid"); } if (leftEyeMaterialSlot < materials.Count) { materialLeftEye = materials[leftEyeMaterialSlot]; } else { Debug.LogWarning("Left eye material index invalid"); } currentLeftEye = 0; currentRightEye = 0; UpdateEyes(); }