Question by
juniorpjg · Nov 12, 2017 at 01:00 AM ·
c#vrscripting beginnervideo
Videoplayer: Simple script for button to jump back 30 seconds.
Hi all,
I am trying to make a simple script for a button for a video player in a VR (VRTK) project that allows me to jump back 30 seconds in the video during playback and resume playback. I am very new to coding and am having trouble getting this to work. I played around with something like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using VRTK;
using UnityEngine.Video;
using UnityEngine.EventSystems;
public class StepBackButton : MonoBehaviour {
public Button stepBackButton;
public VideoPlayer video;
private void OnPointerClick()
{
video.time = video.time -= 30.0;
}
}
Any pointers would be much appreciated.
Comment
Answer by juniorpjg · Nov 13, 2017 at 06:49 PM
Actually was able to figure this one out myself after some more trial and error. This worked for me:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class Reverse30Button : MonoBehaviour {
public VideoPlayer video;
public void Reverse30Seconds()
{
video.time = video.time -= 30.0;
}
}
Your answer
Follow this Question
Related Questions
load scene after video ended 2 Answers
Tetxure swap using HTC controllers 0 Answers
hide object with mouse enter 0 Answers
Move UI with / corresponding Game Object? 1 Answer
How do I make a 2D player controlled ball roll when moving? 1 Answer