void Start()
    {
        CTI = new Rect(0, 0, 0, 0);

        style.fontSize         = timecodeSize;
        style.normal.textColor = Color.white;

        if (playMode == UVT_PlayMode.PingPong && pingpongStartsWithReverse)
        {
            //loopNumber--;
            index         = lastFrame;
            playDirection = UVT_PlayDirection.backward;
        }
        else
        {
            index = firstFrame;
        }

        if (audioAttached)
        {
            myAudio.attachedAudioSource = GetComponent <AudioSource>();
            myAudio.fps        = FPS;
            myAudio.frameIndex = firstFrame;
        }

        playState = UVT_PlayState.Paused;

        if (autoPlay)
        {
            Play();
        }
    }
Esempio n. 2
0
	void Start ()
	{
		// Enables / Disables controls
		
		if (enableControls)
		{
			scrollBar.gameObject.active = true;
			CTI.gameObject.active = true;
			timeCode.gameObject.active = true;
			
			HandleControls();
			
			scrollBarLength = scrollBar.GetComponent<MeshFilter>().mesh.bounds.extents.x;
			timeCode.GetComponent<Renderer>().sharedMaterial.shader = Shader.Find("GUI/3D Text Depth Aware Shader");
		}	
		else
		{
			if (scrollBar != null)
				scrollBar.gameObject.active = false;
			if (CTI != null)
				CTI.gameObject.active = false;
			if (timeCode != null)
				timeCode.gameObject.active = false;
		}
		
		if (playMode == UVT_PlayMode .PingPong && pingpongStartsWithReverse)
		{
			currentLoop--;
			index = lastFrame;
			playDirection = UVT_PlayDirection.backward;
		}
		else
			index = firstFrame;
		
		// Sets up audio for playback
		
		if (audioAttached)
		{
			myAudio.attachedAudioSource = GetComponent<AudioSource>();
			myAudio.fps = FPS;
			myAudio.frameIndex = firstFrame;
		}
		
		// Assigns the layer to the chosen channel
		
		switch (textureType)
		{
		case TextureType.Diffuse:
			texType = "_MainTex";
			break;
		case TextureType.NormalMap:
			texType = "_BumpMap";
			break;
		case TextureType.DetailMap:
			texType = "_Detail";
			break;
		case TextureType.Illumination:
			texType = "_Illum";
			break;
		case TextureType.HeightMap:
			texType = "_ParallaxMap";
			break;
		}
		
		playState = UVT_PlayState.Paused;
		
		if (autoPlay)
			Play();
	}
Esempio n. 3
0
	// Changes direction of playback
	
	public void ChangeDirection(UVT_PlayDirection newUVT_PlayDirection)
	{
		playDirection = newUVT_PlayDirection;
		UpdatePlayFactor();
		UpdateAudio();
	}
Esempio n. 4
0
	void Update () 
	{
		// Checks if played all loops
		
		if (currentLoop == numberOfLoops)
		{
			if (autoLoadLevelWhenDone)
				Application.LoadLevel(LevelToLoad);
			else
				if (autoDestruct)
				{
					Destroy(scrollBar.transform.parent.gameObject);
					Destroy(gameObject);
				}
				else
					Stop();
		}
		
		intIndex = (int)index;
		
		currentPosition = (float)(intIndex - firstFrame) / (lastFrame - firstFrame); // Calculates current position of playback
		
		if (enableControls)
			HandleControls();
		
		// Defaults to forward playback on first frame
		
		if (index <= firstFrame)
		{
			index = firstFrame;
				
			if (playState == UVT_PlayState.Playing)  
			{
				playDirection = UVT_PlayDirection.forward;
				UpdatePlayFactor();
				UpdateAudio();
			}
		}
		
		// Handles play modes on last frame
		
		if (index >= lastFrame) 
		{
			if (playState == UVT_PlayState.Playing)
			{	
				if (playMode != UVT_PlayMode .Random)
					currentLoop++;
				
				if (playMode == UVT_PlayMode .Loop)
				{
					index = firstFrame;
					Play();
				}
				else
					if (playMode == UVT_PlayMode .Once)
					{
						index = lastFrame;
					}
					else
						if (playMode == UVT_PlayMode .PingPong)
							{
 								playDirection = UVT_PlayDirection.backward;
								UpdatePlayFactor();
							}
			}
		}
		if ((playMode == UVT_PlayMode .Random) && (intIndex != lastIndex))
			{
				intIndex = Random.Range(firstFrame,lastFrame);
				index = intIndex;
			}
		
		// Memory management (Low memory modes)
		
		if (intIndex != lastIndex)	
		{
			if (lowMemoryMode == LowMemoryMode.Normal)
			{
				Resources.UnloadAsset(lastTex);
				lastTex = newTex;
			}
			else
			if (lowMemoryMode == LowMemoryMode.BruteForce)
				Resources.UnloadUnusedAssets();
				
			indexStr = string.Format("{0:" + digitsFormat + "}", intIndex); 
			
			if (digitsLocation == DigitsLocation.Postfix)
				newTex = Resources.Load(FileName + indexStr) as Texture;
			else
				newTex = Resources.Load(indexStr + FileName) as Texture;
			
			if (sharedMaterial)					
				GetComponent<Renderer>().sharedMaterial.SetTexture(texType, newTex);
			else
				GetComponent<Renderer>().material.SetTexture(texType, newTex);
				
			lastIndex = intIndex;
		}
		
		if (playState == UVT_PlayState.Playing)
			index += playFactor * (FPS * Time.deltaTime);
		
		// When enabled (via public forceAudioSync) forces Video/Audio sync with each update (Disabled by default)
		
		if (enableAudio && forceAudioSync && playState == UVT_PlayState.Playing)
			ForceAudioSync();
				
	}
    void Update()
    {
        // Checks if played all loops

        if (loopNumber == numberOfLoops)
        {
            if (autoLoadLevelWhenDone)
            {
                Application.LoadLevel(LevelToLoad);
            }
            else
            {
                Stop();
                if (autoHideWhenDone)
                {
                    enableGUI = false;
                }
            }
        }

        HandleControls();

        intIndex = (int)index;

        currentPosition = (float)(intIndex - firstFrame) / (lastFrame - firstFrame);

        /// Defaults to normal play on first frame

        if (intIndex <= firstFrame)
        {
            if (playState == UVT_PlayState.Playing)
            {
                playDirection = UVT_PlayDirection.forward;
                UpdatePlayFactor();
            }
        }

        // Handles play modes on last frame

        if (index >= lastFrame)
        {
            if (playState == UVT_PlayState.Playing)
            {
                loopNumber++;

                if (playMode == UVT_PlayMode.Loop)
                {
                    index = firstFrame;
                    Play();
                }
                else
                if (playMode == UVT_PlayMode.Once)
                {
                    index = lastFrame;
                }
                else
                if (playMode == UVT_PlayMode.PingPong)
                {
                    playDirection = UVT_PlayDirection.backward;
                    UpdatePlayFactor();
                }
            }
        }

        if ((playMode == UVT_PlayMode.Random) && (intIndex != lastIndex))
        {
            intIndex = Random.Range(firstFrame, lastFrame);
            index    = intIndex;
        }

        //Memory management

        if (intIndex != lastIndex)
        {
            if (lowMemoryMode == LowMemoryMode.Normal)
            {
                Resources.UnloadAsset(lastTex);
                lastTex = newTex;
            }
            else
            if (lowMemoryMode == LowMemoryMode.BruteForce)
            {
                Resources.UnloadUnusedAssets();
            }

            indexStr = string.Format("{0:" + digitsFormat + "}", intIndex);

            if (digitsLocation == DigitsLocation.Postfix)
            {
                newTex = Resources.Load(FileName + indexStr) as Texture;
            }
            else
            {
                newTex = Resources.Load(indexStr + FileName) as Texture;
            }

            lastIndex = intIndex;
        }
    }
	void Start ()
	{	
		CTI = new Rect(0,0,0,0);
		
		style.fontSize = timecodeSize;
	 	style.normal.textColor = Color.white;
		
		if (playMode == UVT_PlayMode.PingPong && pingpongStartsWithReverse)
		{
			//loopNumber--;
			index = lastFrame;
			playDirection = UVT_PlayDirection.backward;
		}
		else
			index = firstFrame;
		
		if (audioAttached)
		{
			myAudio.attachedAudioSource = GetComponent<AudioSource>();
			myAudio.fps = FPS;
			myAudio.frameIndex = firstFrame;
		}
		
			playState = UVT_PlayState.Paused;
			
		if (autoPlay)
			Play();
	}
	void Update () 
	{
		// Checks if played all loops
		
		if (loopNumber == numberOfLoops)
		{
			if (autoLoadLevelWhenDone)
				Application.LoadLevel(LevelToLoad);
			else
			{
				Stop();
				if (autoHideWhenDone)
					enableGUI = false;
			}
		}
		
		HandleControls();
		
		intIndex = (int)index;
		
		currentPosition = (float)(intIndex - firstFrame) / (lastFrame - firstFrame);
		
		/// Defaults to normal play on first frame
		
		if (intIndex <= firstFrame)
		{
			if (playState == UVT_PlayState.Playing)  
			{
				playDirection = UVT_PlayDirection.forward;
				UpdatePlayFactor();
			}
		}
		
		// Handles play modes on last frame
		
		if (index >= lastFrame)
		{
			if (playState == UVT_PlayState.Playing)
			{	
				loopNumber++;
				
				if (playMode == UVT_PlayMode.Loop)
				{
					index = firstFrame;
					Play();
				}
				else
					if (playMode == UVT_PlayMode.Once)
						index = lastFrame;
					else
						if (playMode == UVT_PlayMode.PingPong)
						{
							playDirection = UVT_PlayDirection.backward;
							UpdatePlayFactor();
						}
			}
		}
		
		if ((playMode == UVT_PlayMode.Random) && (intIndex != lastIndex))
			{
				intIndex = Random.Range(firstFrame,lastFrame);
				index = intIndex;
			}
		
		//Memory management
				
		if (intIndex != lastIndex)	
		{
			if (lowMemoryMode == LowMemoryMode.Normal)
			{
				Resources.UnloadAsset(lastTex);
				lastTex = newTex;
			}
			else
			if (lowMemoryMode == LowMemoryMode.BruteForce)
				Resources.UnloadUnusedAssets();
				
			indexStr = string.Format("{0:" + digitsFormat + "}", intIndex); 
			
			if (digitsLocation == DigitsLocation.Postfix)
				newTex = Resources.Load(FileName + indexStr) as Texture;
			else
				newTex = Resources.Load(indexStr + FileName) as Texture;
			
			lastIndex = intIndex;
		}
	}