示例#1
0
    int sem = 0; //counter which define play and stop beahaviour in Update()
    void Update()
    {
        if (sem == 0 && p.getStatus() == "play")
        {
            StartCoroutine(this.coroutine);
            ++sem;
        }

        if (sem == 1 && p.getStatus() != "play")
        {
            StopCoroutine(this.coroutine);
            --sem;
        }

        int currentStep = imgmanager.getLevel();

        if (currentStep != prevStep)
        {
            if (currentStep > transform.childCount) //make this dynamic
            {
                return;
            }
            switch_visibility(currentStep);
            //start animation
            this.coroutine = transform.GetChild(currentStep - 1).GetComponent <ElementStartAnimation>().play(wait);
            if (p.getStatus() == "play")
            {
                StartCoroutine(this.coroutine);
            }

            prevStep = currentStep;
        }
    }