public bool PreviousStep() { Transform currPart = transform.GetChild(currPartIdx); if (currPart.GetComponent <Step>() != null) { currPartIdx--; // Edge case: When we step back into a sub model first move it // into start position without executing any steps currPart = transform.GetChild(currPartIdx); SubModel currentSubModel = currPart.GetComponent <SubModel>(); if (currentSubModel != null) { currentSubModel.transform.localPosition = currentSubModel.startPosition; return(true); } } for (; currPartIdx >= 0; currPartIdx--) { currPart = transform.GetChild(currPartIdx); Step previousStep = currPart.GetComponent <Step>(); if (previousStep != null) { return(true); } SubModel nestedSubModel = currPart.GetComponent <SubModel>(); if (nestedSubModel != null) { nestedSubModel.transform.localPosition = nestedSubModel.startPosition; if (!nestedSubModel.PreviousStep()) { continue; } return(true); } currPart.gameObject.SetActive(false); } currPartIdx = 0; return(false); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.C)) { rootModel.ClearSteps(); ready = true; } if (ready && Input.GetKeyDown(KeyCode.F)) { rootModel.NextStep(); } if (ready && Input.GetKeyDown(KeyCode.R)) { rootModel.PreviousStep(); } }
public void PreviousStep() { rootModel.PreviousStep(); }