public void SetArrowColor(bool isDefault, bool isLeftArrow) { string arrowString = isLeftArrow ? "ArrowLeft" : "ArrowRight"; GameObject arrow = gameObject.transform.Find(arrowString).gameObject; if (arrow == null) { return; } ArrowScript script = arrow.GetComponent <ArrowScript>(); if (script == null) { return; } if (isDefault) { script.SetDefaultColor(); } else { script.SetVisualizationColor(); } }