Starting and stop script simultaneously with Play/Pause Button of a video
For a school project I have to track the eye-behaviour of participants in VR via Eye-Tracking. I integrated some Videos into Unity which contain different tasks. The Video is controlled by a simple Play/Pause Button. I also have a SaveData script that saves the tracked Data of the eye-behaviour in a csv file. Since I don't want an abundance of tracked Data, I wanted to know if it's possible to start and stop the SaveData script simultaneously with the Play/Pause Button of the Video.
Due to the fact that I am very new to c# and Unity I have no clue what functions might bring me the planned outcome.
I hope somebody can help me, I would be really thankful.
Answer by furtiscool · Mar 19, 2019 at 12:52 PM
Okay, I found out myself. ^^
This is the Code I needed
public void OnOff()
{
GetComponent<NewRecording>().enabled = !GetComponent<NewRecording>().enabled;
}
}
Since a Script can be seen as a Coponent you can just write a script that is enabling and disabling it. The Script has to be attached to the same object as the script that you want to Control. And the you can just Connect it with a Button.
Your answer
Follow this Question
Related Questions
pressing/turning something in VR to do stuff 0 Answers
How do I create a Continuous Turn in XR for my VR Rig instead of Snap Turn Provider? 0 Answers
Video Player problems on iOS (Unity 2018) 0 Answers
Changing eye height with steamVR Camera Rig 2 Answers
Videoplayer: Simple script for button to jump back 30 seconds. 1 Answer