- Home /
Change float value with Button Onclick
I have this timer script to let an object disappear. By giving sec a value I can adjust the time. But now I want to access and change this value from Button > OnClick so I started function SecVideo. How do I let this function make adjusting the float sec possible with a button click event?
using UnityEngine;
using System.Collections;
public class timer : MonoBehaviour {
public float sec;
public void SecVideo(float sec)
{}
void Start()
{ StartCoroutine(LateCall());
}
IEnumerator LateCall()
{
yield return new WaitForSeconds(sec);
gameObject.SetActive(false);
//Do Function here...
}
// Update is called once per frame
void Update () {
}
}
Answer by NeverHopeless · Jul 08, 2015 at 10:47 AM
Perhaps like:
public void SecVideo(float sec)
{
this.sec = sec;
}
and in unity this parameter sec
should be appear like specified in this image:
Your answer
Follow this Question
Related Questions
Button Canvas OnClick no LoadScene 1 Answer
How to I get the timer counter to restart when the player hits the ground and respawns? 2 Answers
assigning an onclick() function to a button after its instantiated 0 Answers
UI Button generated in runtime OnClick event 0 Answers
How do I implement a timer into this script that will record the total time the player has played. 2 Answers