/* Changes the material of the toggle and either starts or stops the ghosting. */ public override IEnumerator Toggle() { if (toggleState == ToggleState.Off) { base.TriggerToggled(); yield return(new WaitForSeconds(toggleAnimationLength / 2)); meshRenderer.material = onMaterial; // Changes material halfway through animation DMS.GS_StartGhosting(); yield return(new WaitForSeconds(toggleAnimationLength / 2)); toggleState = ToggleState.On; yield return(null); } else { base.TriggerToggled(); yield return(new WaitForSeconds(toggleAnimationLength / 2)); meshRenderer.material = offMaterial; // Changes material halfway through animation DMS.GS_StopGhosting(); yield return(new WaitForSeconds(toggleAnimationLength / 2)); toggleState = ToggleState.Off; yield return(null); } }