55 lines
1.3 KiB
C#
55 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Video;
|
|
|
|
public class VideoManager : MonoBehaviour {
|
|
|
|
private VideoPlayer videoPlayer;
|
|
public float speed {get; set; }
|
|
public float raceFinishTime = 30.0f;
|
|
public int videoID;
|
|
|
|
void Awake() {
|
|
//videoPlayer = gameObject.AddComponent<VideoPlayer>();
|
|
}
|
|
|
|
VideoPlayer GetVideoPlayer() {
|
|
if (videoPlayer == null)
|
|
videoPlayer = gameObject.AddComponent<VideoPlayer>();
|
|
return videoPlayer;
|
|
}
|
|
|
|
void Start () {
|
|
// TODO: Aspect Ratio is not working?
|
|
var vp = GetVideoPlayer();
|
|
vp.aspectRatio = VideoAspectRatio.FitOutside;
|
|
Debug.Log(vp.aspectRatio);
|
|
vp.isLooping = true;
|
|
vp.playOnAwake = false;
|
|
vp.Prepare();
|
|
vp.Pause();
|
|
//videoPlayer.Play();
|
|
Run();
|
|
}
|
|
|
|
public void SetSkin(int playerID) {
|
|
Debug.Log("PID: " + playerID);
|
|
int id = GameManager.Instance.GetSkins(playerID);
|
|
Debug.Log("PID: " + playerID + " id: " + id);
|
|
var vp = GetVideoPlayer();
|
|
vp.url = Application.streamingAssetsPath + "/" + id + ".webm";
|
|
}
|
|
|
|
void Update () {
|
|
videoPlayer.playbackSpeed = speed;
|
|
}
|
|
|
|
void Run() {
|
|
videoPlayer.Play();
|
|
}
|
|
|
|
void WheelImpulse() {
|
|
}
|
|
}
|