Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
186 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...