- Home /
I need help with button not triggering for second time,How to make button trigger procedure again.
So i have one video playing in loop and then when i press left key on keyboard i trigger second video which when its done playing dissaper and i can see first video again but te problem is that only work once first time i press play and when i want to repeat that action my button wont work so can someone help me how to make button do that multiple time so that i can go back and fort between my videos.
This is my button code: public class Play : MonoBehaviour { public GameObject VideoPlayer; public KeyCode left_arrow;
private void Start()
{
}
void Update()
{
if (Input.GetKeyDown(left_arrow))
{
GetComponent<Button>().onClick.Invoke();
}
}
}
And my video code: public class SakrijVideo : MonoBehaviour { public GameObject VideoPlayer; public VideoPlayer Video; public bool PokrenutPlayer = false;
void Start()
{
}
void Update()
{
if (PokrenutPlayer == false && Video.isPlaying == true)
{
PokrenutPlayer = true;
}
if (PokrenutPlayer == true && Video.isPlaying == false)
{
gameObject.GetComponent<VideoPlayer>().enabled = false;
}
}
},So i have first video playing in loop and then when i press left arrow on keyboard i trigger second video which when its done playing disable it self and then i can see 1 video again but that only works once. I need to call that second video multiple times so how can i make button to do again what he did first time
Here is button code: public class Play : MonoBehaviour { public GameObject VideoPlayer; public KeyCode left_arrow;
private void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(left_arrow))
{
GetComponent<Button>().onClick.Invoke();
}
}
}
Here is video code: public class SakrijVideo : MonoBehaviour { public GameObject VideoPlayer; public VideoPlayer Video; public bool PokrenutPlayer = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (PokrenutPlayer == false && Video.isPlaying == true)
{
PokrenutPlayer = true;
}
if (PokrenutPlayer == true && Video.isPlaying == false)
{
gameObject.GetComponent<VideoPlayer>().enabled = false;
}
}
}
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Problem with onClick.AddListener 1 Answer
Video Plane on Image Target - Replay Button (Beginner level) 0 Answers
Ui Button with multiple text prompts 1 Answer