示例#1
0
        IEnumerator Co(float time, Action <float> execute, Action callback, bool realtime)
        {
            WaitForSecondsRT wait = new WaitForSecondsRT(time);

            execute(0);
            float t = 0;

            while (t <= 1 && time > 0)
            {
                if (realtime)
                {
                    t += Time.unscaledDeltaTime / time;
                }
                else
                {
                    t += Time.deltaTime / time;
                }
                execute(t);
                if (realtime)
                {
                    yield return(wait.NewTime(Time.unscaledDeltaTime));
                }
                else
                {
                    yield return(null);
                }
            }
            execute(1);
            coroutine     = null;
            this.callback = null;
            if (callback != null)
            {
                callback();
            }
        }
示例#2
0
    private IEnumerator ChooseLevelCo(string level)
    {
        WaitForSecondsRT wait = new WaitForSecondsRT(1);

        yield return(new WaitForSecondsRT(2f));

        AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(level);

        while (!asyncOperation.isDone)
        {
            yield return(null);
        }
    }
示例#3
0
    private IEnumerator RebindKeyCo(string ButtonName, string oldValue)
    {
        WaitForSecondsRT wait    = new WaitForSecondsRT(1);
        string           keyName = "N/A";

        do
        {
            if (Input.anyKeyDown)
            {
                foreach (KeyCode kc in Enum.GetValues(typeof(KeyCode)))
                {
                    if (Input.GetKeyDown(kc))
                    {
                        keyName = kc.ToString();
                        break;
                    }
                }
                break;
            }
            yield return(wait.NewTime(0.0001f));
        }while(true);

        yield return(new WaitForSecondsRealtime(0.1f));

        foreach (KeyValuePair <string, TMPro.TMP_Text> entry in buttonKeys)
        {
            if (entry.Key != ButtonName && entry.Value.text == keyName)
            {
                entry.Value.text = oldValue;
                inputManager.SetKey(entry.Key, (KeyCode)System.Enum.Parse(typeof(KeyCode), oldValue));
                break;
            }
        }
        buttonKeys[ButtonName].text = keyName;
        inputManager.SetKey(ButtonName, (KeyCode)System.Enum.Parse(typeof(KeyCode), keyName));
    }