Answer the question
In order to leave comments, you need to log in
How to remove unnecessary button presses?
I am new to writing code. I am writing an android application in Unity, a problem arose - there is a long list of sections in one of the scenes, and when scrolling the list, the section buttons are pressed, and these are already unnecessary actions. Tell me how to get rid of this unnecessary pressing?
I thought to implement this by limiting the time of pressing the buttons, that is, if the button is held for more than 1 second, then its action is not performed. But I don't know how to do it, please help me! Here is the part of the code with the buttons, how do I implement it here?:
void OnMouseUpAsButton () {
switch (gameObject.name) {
case "Interest":
SceneManager.LoadScene("Interest");
break;
case "Other":
SceneManager.LoadScene("Other");
break;
}
}
Answer the question
In order to leave comments, you need to log in
In general, I found a way out of this situation, I just initially did everything wrong, you don’t need to switch scenes with a script by clicking on the gameObject, well, at least in the case when you need to scroll the page. I just used the standard buttons in the UI and attached this script to the OnClick function:
using UnityEngine;
using System.Collections;
public class ButtonSkroll : MonoBehaviour {
public void ChangeScene(string sceneName) {
Application.LoadLevel (sceneName);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question