Exemplo n.º 1
0
    public void statusCheckLoop()
    {
#if UNITY_EDITOR
        HAPI_State state = HAPI_State.HAPI_STATE_STARTING_LOAD;
        prCurrentValue = 0;
        prTotal        = 100;

        bool progress_cancelled = false;

        while ((int)state > (int)HAPI_State.HAPI_STATE_MAX_READY_STATE)
        {
            state = (HAPI_State)HoudiniHost.getStatus(HAPI_StatusType.HAPI_STATUS_COOK_STATE);

            if (state == HAPI_State.HAPI_STATE_COOKING)
            {
                prCurrentValue = HoudiniHost.getCookingCurrentCount();
                prTotal        = HoudiniHost.getCookingTotalCount();
            }
            else
            {
                prCurrentValue = (System.DateTime.Now - prStartTime).Seconds;
                prTotal        = 100;
            }

            prMessage = HoudiniHost.getStatusString(
                HAPI_StatusType.HAPI_STATUS_COOK_STATE,
                HAPI_StatusVerbosity.HAPI_STATUSVERBOSITY_WARNINGS);

            if (progress_cancelled)
            {
                EditorUtility.DisplayProgressBar(prTitle, "Aborting...", 0);
            }
            else
            {
                try
                {
                    displayProgressBar();
                }
                catch (HoudiniErrorProgressCancelled)
                {
                    progress_cancelled = true;
                    EditorUtility.DisplayProgressBar(prTitle, "Aborting...", 0);
                }
            }
        }

        // We want to propage the cancellation of the progress still, even if it is after a delay.
        if (progress_cancelled)
        {
            throw new HoudiniErrorProgressCancelled();
        }

        if (state == HAPI_State.HAPI_STATE_READY_WITH_COOK_ERRORS)
        {
            state = HAPI_State.HAPI_STATE_READY;
            string messages = HoudiniHost.getCookErrorMessage();
            HoudiniHost.logWarning(messages);
        }
        else if (state == HAPI_State.HAPI_STATE_READY_WITH_FATAL_ERRORS)
        {
            state = HAPI_State.HAPI_STATE_READY;
            HoudiniHost.throwCookError();
        }
#endif // UNITY_EDITOR
    }