float GetMovePercent(SwitchBoxSwitch sw) { var totalDist = (rightAnchor.position - leftAnchor.position).magnitude; var swPos = sw.transform.position; var swDist = (swPos - leftAnchor.position).magnitude; return(swDist / totalDist); }
void UpdateUpStates() { curSwitch = GetOneOnSwitch(); isUp = curSwitch != null; if (curSwitch != null) { curRodPosPerc = 1 - GetMovePercent(curSwitch); } }
SwitchBoxSwitch GetOneOnSwitch() { SwitchBoxSwitch onSwitch = null; foreach (var item in switchList) { if (item.IsSwitchOn()) { onSwitch = item; } } return(onSwitch); }
// Start is called before the first frame update void Start() { sw = GetComponent <SwitchBoxSwitch>(); }