コード例 #1
0
        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);
        }
コード例 #2
0
        // 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();
            }
        }
コード例 #3
0
 public void PreviousStep()
 {
     rootModel.PreviousStep();
 }