Exemplo n.º 1
0
    public static IEnumerator Parallel(MonoBehaviour routinesHolder, IEnumerable <IEnumerator> routines)
    {
        int waitingCounter = 0;

        foreach (var routine in routines)
        {
            if (null == routine)
            {
                continue;
            }

            ++waitingCounter;

            routinesHolder.StartCoroutine(
                Routines.Concat(
                    routine,
                    Routines.Action(() => -- waitingCounter)
                    )
                );
        }

        while (waitingCounter > 0)
        {
            yield return(null);
        }
    }
Exemplo n.º 2
0
    private void InitializeSingleton()
    {
        if (s_earlyInstance)
        {
            Destroy(gameObject);
            return;
        }

        s_earlyInstance = this;
        DontDestroyOnLoad(gameObject);

        var init = Initialize();

        if (null != init)
        {
            init = Routines.Concat(init, Routines.Action(() => { Instance = this as SingletonType; }));
            StartCoroutine(init);
        }
        else
        {
            Instance = this as SingletonType;
        }
    }