private void RecolourWall(StretchableCube wall, float time) { Color color = ColourManager.GetBarrierColour(time); if (color == ColourManager.DefaultBarrierColour || color == Color.clear) { return; } foreach (Transform component in wall.transform.parent.parent) { foreach (Transform child in component.transform) { MeshRenderer ren = child.GetComponent <MeshRenderer>(); if (ren.material.color != Color.clear) { ren.material.color = color; } } } MeshRenderer r = wall.GetComponent <MeshRenderer>(); float cor = (3f * ColourManager.barrierColourCorrectionScale) + 1;//4f * ColourManager.barrierColourCorrectionScale; r.material.SetColor("_AddColor", (color / (4f * ColourManager.barrierColourCorrectionScale)).ColorWithAlpha(0f)); }
private void RecolourWall(StretchableCube wall, Color color) { CustomUI.Utilities.UIUtilities.PrintHierarchy(wall.transform.parent); foreach (Transform component in wall.transform.parent) { foreach (Transform child in component.transform) { try { MeshRenderer ren = child.GetComponent <MeshRenderer>(); if (ren.material.color != Color.clear) { ren.material.color = color; } } catch (Exception) { // This doesn't have a color // It could be the Collider } } } MeshRenderer r = wall.GetComponent <MeshRenderer>(); r.material.SetColor("_AddColor", color); }