1
Misc Archive / Repeat button on javascript
« on: August 03, 2014, 07:54:53 AM »
Hey guys, I have a question I don't know C# programming language so I work in JS, I use free NGUI version.According to my research I found something.I want to make repeat button in JS but all repeat button example is in C#
using UnityEngine;
And I make this in Javascript how I do it? I hope to understand what I mean. Thank you
using UnityEngine;
- public class RepeatButtons : MonoBehaviour
- {
- public float delay = 1.00f;
- public float interval = 0.25f;
- bool mIsPressed = false;
- float mNextClick = 0f;
- void OnPress (bool isPressed)
- {
- mIsPressed = isPressed;
- mNextClick = Time.realtimeSinceStartup + delay;
- // Perform action as soon as button is pressed.
- if (isPressed)
- PerformAction();
- }
- void Update ()
- {
- // Adjusted condition slightly...
- if (mIsPressed && Time.realtimeSinceStartup >= mNextClick)
- {
- mNextClick = Time.realtimeSinceStartup + interval;
- PerformAction();
- }
- }
- void PerformAction() {
- //Do something
- }
- }
And I make this in Javascript how I do it? I hope to understand what I mean. Thank you
