unity3d - How to select a UI button based on a time triggered gaze input using GVr and unity? -
i using unity5 , gvr.i trying implement menu user stares @ button 5secs button enabled.can please me? have implemented reticle , detects button.i not sure how , should add time trigger.
attach script button object:
[requirecomponent(typeof(button))] public class interactiveitem : monobehaviour, ipointerenterhandler, ipointerexithandler { public image progressimage; // add image child button object , set image type filled. assign field in inspector. public bool isentered = false; recttransform rt; button _button; float timeelapsed; image cursor; // use initialization void awake () { _button = getcomponent<button>(); rt = getcomponent<recttransform>(); } float gazeactivationtime = 3; void update () { if(isentered) { timeelapsed += time.deltatime; progressimage.fillamount = mathf.clamp(timeelapsed/gazeactivationtime,0,1); if(timeelapsed >= gazeactivationtime) { timeelapsed = 0; _button.onclick.invoke(); progressimage.fillamount = 0; isentered = false; } } else { timeelapsed = 0; } } #region ipointerenterhandler implementation public void onpointerenter (pointereventdata eventdata) { isentered = true; } #endregion #region ipointerexithandler implementation public void onpointerexit (pointereventdata eventdata) { isentered = false; progressimage.fillamount = 0; } #endregion
Comments
Post a Comment