public void Volume() { //(buttonName == "Volume1" || buttonName == "Volume2") int tempNum = (int)char.GetNumericValue(tempButtonName [tempButtonName.Length - 1]); //This is the last number on the pattern string i.e. Pattern1: where 1 is tempNum. //Debug.Log (tempNum); if (tempNum == 1) { SM_Script.IncreaseVolume(); } else { SM_Script.DecreaseVolume(); } VolumeSubTask(); }