37 lines
1.0 KiB
C#
37 lines
1.0 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 void SetSkin(int playerID) {
|
|
videoPlayer = gameObject.AddComponent<VideoPlayer>();
|
|
|
|
var gm = GameManager.Instance;
|
|
|
|
int id = gm.GetSkins(playerID);
|
|
videoPlayer.url = Application.streamingAssetsPath + "/" + id + ".webm";
|
|
|
|
Debug.Log("Video Stats:" +
|
|
" canSetTime: " + videoPlayer.canSetTime +
|
|
" canSetSkipOnDrop: " + videoPlayer.canSetSkipOnDrop);
|
|
|
|
videoPlayer.skipOnDrop = true;
|
|
videoPlayer.isLooping = false;
|
|
videoPlayer.playOnAwake = false;
|
|
videoPlayer.Prepare();
|
|
|
|
float startTime = gm.GetVideoEnd(id) - gm.GetRaceNormalTime();
|
|
videoPlayer.time = startTime;
|
|
videoPlayer.Play();
|
|
}
|
|
|
|
void Update () {
|
|
videoPlayer.playbackSpeed = speed;
|
|
}
|
|
}
|