Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jun 2017
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy i need coding help c#

    underneath is the code i have written and for some reason it wont play the videos fully and when i press space it doesnt do the thing.

    Code:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class code : MonoBehaviour {
    	
    	void Start () 
    	{
    	GameObject camera = GameObject.Find ("Main Camera");
    	var videoPlayer = camera.AddComponent<UnityEngine.Video.VideoPlayer> ();
    	videoPlayer.renderMode = UnityEngine.Video.VideoRenderMode.CameraFarPlane;
    	videoPlayer.url = "C:\\Users\\msi\\Desktop\\Finalmajor\\FinalStuff\\FinalStuff\\4x4\\Start.mp4";
    	videoPlayer.isLooping = true;
    	}
    	IEnumerator TimerRoutine() {
    		
    		if (Input.GetKeyDown (KeyCode.Space)) {
    			var chose = Random.Range (0, 3);
    			if (chose == (1)) {
    				{
    					GameObject camera = GameObject.Find ("Main Camera");
    					var videoPlayer = camera.AddComponent<UnityEngine.Video.VideoPlayer> ();
    					videoPlayer.renderMode = UnityEngine.Video.VideoRenderMode.CameraFarPlane;
    					videoPlayer.url = "C:\\Users\\msi\\Desktop\\Finalmajor\\FinalStuff\\FinalStuff\\4x4\\1st animation.mp4";
    					yield return new WaitForSeconds (40.0f);
    					videoPlayer.url = "C:\\Users\\msi\\Desktop\\Finalmajor\\FinalStuff\\FinalStuff\\4x4\\Start.mp4";
    					videoPlayer.isLooping = true;
    			}
    		}
    
    			if (chose == (2)) {
    					GameObject camera = GameObject.Find ("Main Camera");
    					var videoPlayer = camera.AddComponent<UnityEngine.Video.VideoPlayer> ();
    					videoPlayer.renderMode = UnityEngine.Video.VideoRenderMode.CameraFarPlane;
    					videoPlayer.url = "C:\\Users\\msi\\Desktop\\Finalmajor\\FinalStuff\\FinalStuff\\4x4\\2nd animation.mp4";
    					yield return new WaitForSeconds (40.0f);
    					videoPlayer.url = "C:\\Users\\msi\\Desktop\\Finalmajor\\FinalStuff\\FinalStuff\\4x4\\Start.mp4";
    					videoPlayer.isLooping = true;
    			}
    		}
    	}
    }
    Last edited by vinyl-junkie; 06-04-2017 at 07:24 PM. Reason: added code tags


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •