private void SetupMaterials(GameObject obj, int[] metaData, int newLayer) { ModelMaterialOptions options = obj.GetComponentInChildren <ModelMaterialOptions>(); bool isMale = metaData[0] == 1; options.leftEye = leftEyes[metaData[1]]; options.rightEye = rightEyes[metaData[2]]; options.hair = hairColours[metaData[3]]; Mesh[] hairstyles = isMale ? maleHairstyles : femaleHairstyles; Vector3[] hatOffset = isMale ? maleHatOffsets : femaleHatOffsets; options.hairstyle = hairstyles[metaData[4]]; options.hatLocalOffset = hatOffset[metaData[4]]; Material[] general = newLayer == 1 ? purpleMaterials : greenMaterials; options.broom = general[0]; options.stick = general[1]; options.clothes = general[2]; options.clothesAccent = general[3]; options.translucent = general[4]; options.UpdateMaterials(); obj.GetComponent <MovementController>().SetProjectileEffect (newLayer == 1 ? purpleProjectileEffect : greenProjectileEffect); ParticleSystem.MainModule m = options.broomParticles.main; m.startColor = (newLayer == 1 ? new Color(0.897f, 0f, 1f, 0.761f) : new Color(0.019f, 0.802f, 0.381f, 0.761f)); }
public void TranslucentMaterials(ModelMaterialOptions options) { Renderer r = GetComponent <Renderer>(); Material[] selected = new Material[r.sharedMaterials.Length]; for (int i = 0; i < selected.Length; i++) { selected[i] = options.translucent; } r.sharedMaterials = selected; }
public void UpdateMaterials(ModelMaterialOptions options) { Material[] selected = new Material[materials.GetLength(0)]; for (int i = 0; i < materials.GetLength(0); i++) { selected[i] = options.Dispatcher(materials[i]); } Renderer r = GetComponent <Renderer>(); r.materials = selected; }
public override void OnInspectorGUI() { DrawDefaultInspector(); ModelMaterialOptions myScript = (ModelMaterialOptions)target; if (GUILayout.Button("Update Materials")) { myScript.UpdateMaterials(); } if (GUILayout.Button("Test Transparency")) { myScript.TranslucentMaterials(); } }