Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
180 views
in Technique[技术] by (71.8m points)

c# - Display a loading icon while search method is working

In unity I worked a game project and I want to UI display loading icon(like spinning circle) while my search method(it returns bool value by the way) is working which takes time about 4-5 seconds. how must be the right algoritm ? I tried coroutine but couldn't integrate it. if someone give example, link or any suggestion I appericated. thanks in advance...

public class myclass : MonoBehaviour
{
    public bool ismethodsearching;
    void Start()
    {
       ismethodsearching = false;
    }

    void Update()
    {
        if (ismethodsearching)
        {
            gameObject.GetComponent<Transform>().Rotate(new Vector3(1,0,0));
        }
    }

    //main duty of this method find whether word is in list or not
    //and also with a global value "ismethodsearching" I want to manage image 
    //rotation
    bool searchmethod(string[] wordlist, string targetword)
    {
        ismethodsearching = true;

        foreach(word in wordlist)
        {
            //some other operations
            if (targetword == wordlist)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        ismethodsearching = false;
    }

    void Startsearchmethod()//when clicked button this method will be called
    {
        Invoke(searchmethod);
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...