void FillTextures(MeshCreator world) { MeshRenderer mr = world.GetComponent <MeshRenderer>(); if (mr != null) { Texture2D tx = (Texture2D)mr.material.mainTexture; if (tx != null) { int width = tx.width; int height = tx.height; for (int x = 0; x < width; x += 64) { for (int y = 0; y < height; y += 64) { var colors = tx.GetPixels(x, y, 64, 64); Texture2D newTexture = new Texture2D(64, 64); newTexture.SetPixels(colors); newTexture.Apply(); // NE PAS OUBLIER SINON IL NE PREND PAS EN COMPTE LES MODIFS m_textures.Add(newTexture); } } } } }
private void FillTexture(MeshCreator p_Instance) { MeshRenderer l_MeshRenderer = p_Instance.GetComponent <MeshRenderer>(); if (l_MeshRenderer != null) { Texture2D l_Texture = l_MeshRenderer.sharedMaterial.mainTexture as Texture2D; if (l_Texture != null) { int l_Width = l_Texture.width; int l_Height = l_Texture.width; int l_Width1 = 64; int l_Height1 = 64; for (int x = 0; x < l_Width; x += l_Width1) { for (int y = 0; y < l_Height; y += l_Height1) { var colors = l_Texture.GetPixels(x, y, l_Width1, l_Height1); Texture2D l_NewTexture = new Texture2D(l_Width1, l_Height1); l_NewTexture.SetPixels(colors); l_NewTexture.Apply(); m_Textures.Add(l_NewTexture); } } } } }
void OnEnable() { myMeshCreator = (MeshCreator)target; myMeshCreator.sortingOrder = myMeshCreator.GetComponent <MeshRenderer>().sortingOrder; if (myMeshCreator.IsLoaded == false) { myMeshCreator.LoadMeshData(); } }
public void Pitch(int num) { float pitchVal = Mathf.Pow(1.05946f, noteDrop.value * (-1.0f)); if (scaleDrop.value == 0) //major { if (num == 0) { pitchVal *= Mathf.Pow(1.05946f, 0); } else if (num == 1) { pitchVal *= Mathf.Pow(1.05946f, 2); } else if (num == 2) { pitchVal *= Mathf.Pow(1.05946f, 4); } else if (num == 3) { pitchVal *= Mathf.Pow(1.05946f, 5); } else if (num == 4) { pitchVal *= Mathf.Pow(1.05946f, 7); } else if (num == 5) { pitchVal *= Mathf.Pow(1.05946f, 9); } else if (num == 6) { pitchVal *= Mathf.Pow(1.05946f, 11); } else if (num == 7) { pitchVal *= Mathf.Pow(1.05946f, 12); } else if (num == 8) { pitchVal *= Mathf.Pow(1.05946f, 14); } else if (num == 9) { pitchVal *= Mathf.Pow(1.05946f, 16); } else if (num == 10) { pitchVal *= Mathf.Pow(1.05946f, 17); } else if (num == 11) { pitchVal *= Mathf.Pow(1.05946f, 19); } else if (num == 12) { pitchVal *= Mathf.Pow(1.05946f, 21); } else if (num == 13) { pitchVal *= Mathf.Pow(1.05946f, 23); } } else if (scaleDrop.value == 1) //minor { if (num == 0) { pitchVal *= Mathf.Pow(1.05946f, 0); } else if (num == 1) { pitchVal *= Mathf.Pow(1.05946f, 2); } else if (num == 2) { pitchVal *= Mathf.Pow(1.05946f, 3); } else if (num == 3) { pitchVal *= Mathf.Pow(1.05946f, 5); } else if (num == 4) { pitchVal *= Mathf.Pow(1.05946f, 7); } else if (num == 5) { pitchVal *= Mathf.Pow(1.05946f, 8); } else if (num == 6) { pitchVal *= Mathf.Pow(1.05946f, 10); } else if (num == 7) { pitchVal *= Mathf.Pow(1.05946f, 12); } else if (num == 8) { pitchVal *= Mathf.Pow(1.05946f, 14); } else if (num == 9) { pitchVal *= Mathf.Pow(1.05946f, 15); } else if (num == 10) { pitchVal *= Mathf.Pow(1.05946f, 17); } else if (num == 11) { pitchVal *= Mathf.Pow(1.05946f, 19); } else if (num == 12) { pitchVal *= Mathf.Pow(1.05946f, 20); } else if (num == 13) { pitchVal *= Mathf.Pow(1.05946f, 22); } } mc.GetComponent <MeshRenderer> ().material.color = Color.HSVToRGB(num / 14.0f, 0.5f, 1.0f); for (int i = 0; i < asrc.Length; i++) { asrc [i].pitch = pitchVal; } }