예제 #1
0
        private IEnumerator PlayMovieLoop(MovieStateDatum stateDatum)
        {
#if !UNITY_ANDROID && !UNITY_WEBGL
            int loopCount = stateDatum.LoopCount;
            while (loopCount > 0)
            {
                stateDatum.targetMovie.Play();
                yield return(new WaitForSeconds(stateDatum.targetMovie.duration));

                loopCount--;
            }
#else
            yield return(null);
#endif
        }
예제 #2
0
        public void SetState(int newState)
        {
#if !UNITY_ANDROID && !UNITY_WEBGL
            if (MovieStates.Length > newState)
            {
                MovieStateDatum stateDatum = MovieStates[newState];
                if (stateDatum.targetMovie != null)
                {
                    mRenderer.material.SetTexture("_MainTex", stateDatum.targetMovie);
                    mRenderer.material.SetTexture("_AlphaTex", stateDatum.targetMovie);
                    stateDatum.targetMovie.loop = stateDatum.LoopMovie;

                    if (stateDatum.LoopCount > 0 && !stateDatum.LoopMovie)
                    {
                        StartCoroutine("PlayMovieLoop", stateDatum);
                    }
                    else
                    {
                        stateDatum.targetMovie.Play();
                    }

                    mRenderer.enabled = true;
                }
                else
                {
                    if (stateDatum.targetTexture != null)
                    {
                        mRenderer.material.SetTexture("_MainTex", stateDatum.targetTexture);
                        mRenderer.material.SetTexture("_AlphaTex", stateDatum.targetTexture);
                        mRenderer.enabled = true;
                    }
                    else
                    {
                        mRenderer.enabled = false;
                    }
                }
            }
            else
            {
                Debug.LogWarning("State Index is Out of Range!");
            }
#endif
        }