bool test = false; //Controlar o carregamento da cena.

    #endregion Fields

    #region Methods

    /*A coroutine abaixo descreve a loading screen, seus objetos sao ativados, o texto que se trata da porcentagem se torna
         * equivalente ao objeto progressbar que cresce durante o carregamento da cena. Caso o mesmo carregamento esteja completo
         * a proxima cena sera carregada*/
    IEnumerator DisplayLoadScreen()
    {
        background.SetActive (true);
        text1.renderer.enabled = true;
        progressbar.SetActive (true);

        progressbar.transform.localScale =
            new Vector3 (progressbar.transform.localScale.x,
                         progressbar.transform.localScale.y, LoadProgress);
        text1.text = LoadProgress + "%";

        async = Application.LoadLevelAsync (2);

                        while (!async.isDone) {
                                LoadProgress = (int)(async.progress * 110);
                                text1.text = LoadProgress + "%";
                                progressbar.transform.localScale =
                new Vector3 (progressbar.transform.localScale.x,

                             progressbar.transform.localScale.y, async.progress);

            yield return null;

                        }
    }
 public void Show(AsyncOperation ao)
 {
     gameObject.SetActive(true);
     bg.SetActive(true);
     isAsyn = true;
     this.ao = ao;
 }
Esempio n. 3
0
	// Use this for initialization
	void Start () {
#if UNITY_5_3
        async =  SceneManager.LoadSceneAsync(GlobalData.NextLevel);
#else
         async =Application.LoadLevelAsync(GlobalData.NextLevel);
#endif
	}
Esempio n. 4
0
 public IEnumerator LoadScene(string SceneName)
 {
     _mCameraGameObject.SetActive(true);
     async = Application.LoadLevelAsync(SceneName);
     async.allowSceneActivation = false;
     yield return async;
 }
Esempio n. 5
0
    IEnumerator Load()
    {
        switch(GameData.Instance.CurrentLevel)
        {
        case Levels.Level_1:
            switch(GameData.Instance.CurrentSection)
            {
            case Sections.Sections_1:
                m_Async = Application.LoadLevelAsync(Constants.LEVEL1_SECTION1);
                break;

            case Sections.Sections_2:
                m_Async = Application.LoadLevelAsync(Constants.LEVEL1_SECTION2);
                break;

            case Sections.Sections_3:
                m_Async = Application.LoadLevelAsync(Constants.LEVEL1_SECTION3);
                break;
            }
            break;
        }
        //		m_Async.allowSceneActivation = false;
        yield return m_Async.isDone;
        yield return SwitchScene();
    }
Esempio n. 6
0
 void Start()
 {
     async = Application.LoadLevelAsync(5);
     async.allowSceneActivation = false;
     //yield return async;
     Debug.Log("Loading complete");
 }
Esempio n. 7
0
    public static IEnumerator LoadLevelSCREEN(string name)
    {
        rnging = true;

        async = Application.LoadLevelAsync(name);
        yield return async;
    }
Esempio n. 8
0
 public void changeScene(string nextScene)
 {
     //Application.LoadLevel(nextScene);
     preloaderScreen.SetActive (true);
     loadOp = Application.LoadLevelAsync(nextScene);
     StartCoroutine (ScenePreload ());
 }
Esempio n. 9
0
 public void Start()
 {
     if (this.SyncRequest == null)
     {
         this.SyncRequest = Res.LoadAsync(this.resourcePath, this.resourceType);
     }
 }
Esempio n. 10
0
                        copyrightVisible = false; //determines if copyright is visible

    #endregion Fields

    #region Methods

    //Loads the next scene.
    IEnumerator AsyncLoadLevel()
    {
        async = Application.LoadLevelAsync("Greenlight Screen");
        async.allowSceneActivation = false;
        yield return async;
        Debug.Log("Loading complete");
    }
	IEnumerator load() {
		Debug.LogWarning("ASYNC LOAD STARTED - " +
		                 "DO NOT EXIT PLAY MODE UNTIL SCENE LOADS... UNITY WILL CRASH");
		async = Application.LoadLevelAsync(sceneToLoad.ToString());
		async.allowSceneActivation = false;
		yield return async;
	}
Esempio n. 12
0
 IEnumerator LoadScene()
 {
     processBar.gameObject.SetActive(true);
     async = Application.LoadLevelAsync("Main");
     async.allowSceneActivation = false;
     yield return async;
 }
	public void show(AsyncOperation ao)
	{
		Debug.Log("ao.progress: " + ao.progress);
		gameObject.SetActive(true);
		bg.SetActive(true);
		progressBar.value = ao.progress;
	}
Esempio n. 14
0
    IEnumerator Workflow()
    {
        FadeIn fadeIn = logo.AddComponent<FadeIn>();
        fadeIn.time = 1.0f;
        fadeIn.Begin();
        yield return new WaitForSeconds(2f);

        FadeOut fadeOut = logo.AddComponent<FadeOut>();
        fadeOut.time = 1.0f;
        fadeOut.Begin();
        yield return new WaitForSeconds(1f);

        logo.SetActive(false);
        loadingLayer.SetActive(true);
        yield return new WaitForEndOfFrame();

        MoveBy move = title.AddComponent<MoveBy>();
        move.offset = new Vector3(0, -2f, 0);
        move.time = 1f;
        move.Begin();
        yield return new WaitForSeconds(1f);

        async = Application.LoadLevelAsync("MainScene");
        async.allowSceneActivation = false;
        yield return StartCoroutine(Loading());

        text.text = "开始游戏";
        button.enabled = true;
    }
Esempio n. 15
0
    private IEnumerator LoadLevel(int iSceneIndex)
    {
        m_LabelProg.gameObject.SetActive(true);

        m_Asyn = SceneManager.LoadSceneAsync (iSceneIndex);
        yield return m_Asyn;
    }
Esempio n. 16
0
	IEnumerator LoadNextLevel()
	{
		async = Application.LoadLevelAsync(1);
		async.allowSceneActivation = false;

		yield return async;
	}
Esempio n. 17
0
 public void GoToLevelScene()
 {
     GameStateManager.setGameState (GameState.Playing);
     a =  Application.LoadLevelAsync ("LevelScene");
     //a.allowSceneActivation = false;
     timeStartLoading = Time.time;
 }
        public void OperationShouldSerializeAsyncMethodWithViewModel()
        {
            var vmMock = new NavigableViewModelMock();
            ServiceProvider.OperationCallbackFactory = new SerializableOperationCallbackFactory();
            var operation = new AsyncOperation<bool>();
            IOperationResult<bool> result = OperationResult.CreateResult(OperationType.PageNavigation, this, true,
                new NavigationContext(NavigationType.Page, NavigationMode.Back, vmMock, vmMock, this));

            AsyncMethodWithViewModel(operation, true, vmMock);
            var callback = operation.ToOperationCallback();
            var serialize = Serializer.Serialize(callback);
            serialize.Position = 0;
            callback = (IOperationCallback)Serializer.Deserialize(serialize);

            IocContainer.GetFunc = (type, s, arg3) =>
            {
                if (type == GetType())
                    return this;
                return Activator.CreateInstance(type);
            };
            AsyncMethodInvoked.ShouldBeFalse();
            ViewModel.ShouldBeNull();
            callback.Invoke(result);
            AsyncMethodInvoked.ShouldBeTrue();
            ViewModel.ShouldEqual(vmMock);
        }
Esempio n. 19
0
    void FixedUpdate()
    {
        if (Input.GetButton("Jump"))
        {
            Debug.Log("Load...");
            if (loadscene != null)
            {
                if (loadscene.progress >= 0.9f) loadscene.allowSceneActivation = true;
            }

            //SceneManager.LoadScene("sceneB");
            //SceneManager.MoveGameObjectToScene(moveobject,SceneManager.GetSceneByName("sceneB"));
            //StartCoroutine(Example());
        }
        else if (Input.GetKeyDown(KeyCode.A))
        {
            Debug.Log("Load Async...");
            loadscene = SceneManager.LoadSceneAsync("sceneB",LoadSceneMode.Additive);
            loadscene.allowSceneActivation = false;
            //SceneManager.MoveGameObjectToScene(moveobject, SceneManager.GetSceneByName("sceneB"));
            //StartCoroutine(Example());
        }
        else if (Input.GetKeyDown(KeyCode.M))
        {
            Debug.Log("Merge...");
            SceneManager.MergeScenes(SceneManager.GetSceneByName("sceneA"), SceneManager.GetSceneByName("sceneB"));
            //StartCoroutine(Example());
        }
        else if (Input.GetKeyDown(KeyCode.U)) {
            if (SceneManager.GetSceneByName("SceneB").isLoaded)
            {
                SceneManager.UnloadScene("SceneB");
            }
        }
    }
Esempio n. 20
0
	IEnumerator Start ()
	{
		if(MenuControllerGenerator.controller)
		{
			unloadUnusedAssets = Resources.UnloadUnusedAssets();
			StartCoroutine("UpdateLoader");
			yield return unloadUnusedAssets;
			StopCoroutine("UpdateLoader");
			MenuControllerGenerator.controller.LoaderIsDoneUnload = true;
			MenuControllerGenerator.controller.progress = 0.2f;
			yield return new WaitForEndOfFrame();

			if(MenuControllerGenerator.controller.levelName != "")
				Application.LoadLevel(MenuControllerGenerator.controller.levelName);
			else
				Application.LoadLevel(MenuControllerGenerator.controller.levelNumber);
		}
		else
		{
			yield return null;
#if UNITY_EDITOR
			if(Application.levelCount >= 3)
				Application.LoadLevel("GameStart");
			else
				Debug.LogError("Please add the scenes (GameStart, Game and Loader) in the File/Build Settings" +
				               " as shown in the image  Assets/BallPool/TagAndLayers.png");
#endif
		}
	}
Esempio n. 21
0
	IEnumerator LoadCurrentScene()//try again
	{
		yield return new WaitForSeconds(1);
		//asyn = Application.LoadLevelAsync ("level3");
		asyn = Application.LoadLevelAsync ("level9");
		yield return new WaitForSeconds(1);
	}
Esempio n. 22
0
    IEnumerator loadScene()
    {
        async = Application.LoadLevelAsync (Globe.getInstance().loadName);
        async.allowSceneActivation = false;
        while(async.progress<0.9f)
        {
            per+=0.01f;
            text.text =Mathf.Floor( per*100)+"%";
            loadingMc.fillAmount = per;
            yield return new WaitForEndOfFrame();
        }

        while (per <1f)
        {
            per+=0.01f;
            text.text =Mathf.Floor( per*100)+"%";
            loadingMc.fillAmount = per;
            yield return new WaitForEndOfFrame();
        }

        if(Globe.getInstance().afterEnterWorldHandler!=null)
        {
            Globe.getInstance().afterEnterWorldHandler();
            Globe.getInstance().afterEnterWorldHandler=null;
        }
        async.allowSceneActivation = true;
    }
        public void ContinueWithActionInterfaceToOperationCallbackTest()
        {
            var operation = new AsyncOperation<bool>();
            IOperationResult<bool> operationResult = OperationResult.CreateResult(OperationType.PageNavigation, this, true,
                DataContext.Empty);

            bool isInvoked = false;
            var continuationAction = new ActionContinuationMock
            {
                Invoke = result =>
                {
                    result.ShouldEqual(operationResult);
                    isInvoked = true;
                }
            };

            operation.ContinueWith(continuationAction);
            isInvoked.ShouldBeFalse();
            operation.ToOperationCallback().Invoke(operationResult);
            isInvoked.ShouldBeTrue();

            isInvoked = false;
            operation.ContinueWith(continuationAction);
            isInvoked.ShouldBeTrue();
        }
Esempio n. 24
0
	IEnumerator loadScene()  
	{  
		isAsync = true;
		async = Application.LoadLevelAsync(Global.GetInstance().loadName);
		async.allowSceneActivation = false;//禁止协程加载完自动跳转关卡
		yield return async;
	}
    public IEnumerator loadSceneAsync(string sceneName)
    {
        async = Application.LoadLevelAsync(sceneName);

        async.allowSceneActivation = false;
        yield return async ;
    }
Esempio n. 26
0
    public void Show(AsyncOperation ao)
    {

        BG.SetActive(true);
        isAsyn = true;
        this.ao = ao;
    }
Esempio n. 27
0
 private IEnumerator LoadALevel(string sceneName)
 {
     yield return new WaitForSeconds(5f);
     async = SceneManager.LoadSceneAsync(sceneName);
     //yield return new WaitForSeconds(6f);
     yield return async;
 }
Esempio n. 28
0
 void StreamLevel()
 {
     if (nextLevelID >= 0) {
         level = Application.LoadLevelAdditiveAsync(nextLevelID);
         level.allowSceneActivation = false;
     }
 }
Esempio n. 29
0
    IEnumerator Load()
    {
        try
        {
            stageName = sc.getStageName().ToString();
            print("stageName: " + stageName);
            // 非同期でロード開始
            async = Application.LoadLevelAsync(stageName.ToString());
            // デフォルトはtrue。ロード完了したら勝手にシーンきりかえ発生しないよう設定。
            async.allowSceneActivation = false;
        }
        catch (Exception)
        {
            Application.LoadLevelAsync("StageSelect");
            yield break;
        }

        // 非同期読み込み中の処理
        while (async.progress < 0.9f)
        {
            loadingText.text = "NowLoading..." + (async.progress * 100).ToString("F0") + "%";
            //Debug.Log("ローディングパーセント" + async.progress * 100);
            lodingBar.value = async.progress;
            yield return new WaitForEndOfFrame();
        }
        lodingBar.value = 0.9f;
        loadingText.text = "NowLoading...100%";
        state.setState(GameState.NotPlaying);
        yield return async;
    }
Esempio n. 30
0
    IEnumerator Start()
    {
        // 非同期でロード開始
        switch(ButtonC.courceNum){
        case 1:
            async0 = Application.LoadLevelAsync("Stage00");
            async0.allowSceneActivation= false;
            yield return async0;
            break;

        case 2:
            async0 = Application.LoadLevelAsync("Stage01");
            async0.allowSceneActivation= false;
            yield return async0;
            break;

        case 3:
            async0 = Application.LoadLevelAsync("Stage10");
            async0.allowSceneActivation= false;
            yield return async0;
            break;

        default:
            break;
        }
    }
Esempio n. 31
0
 public IAsyncOperation <string> InvokeScriptAsync(string scriptName, IEnumerable <string> arguments) =>
 AsyncOperation.FromTask(ct => InvokeScriptAsync(ct, scriptName, arguments?.ToArray()));
Esempio n. 32
0
    // Corourtine to handle all the steps across loading boundaries.
    IEnumerator LoadLevel()
    {
        // Optionally rotate loading screen transform around the camera into view.
        // We assume here that the loading screen is already facing toward the origin,
        // and that the progress bar transform (if any) is a child and will follow along.
        if (loadingScreen != null && loadingScreenDistance > 0.0f)
        {
            // Wait until we have tracking.
            var hmd = SteamVR_Controller.Input((int)OpenVR.k_unTrackedDeviceIndex_Hmd);
            while (!hmd.hasTracking)
            {
                yield return(null);
            }

            var tloading = hmd.transform;
            tloading.rot  = Quaternion.Euler(0.0f, tloading.rot.eulerAngles.y, 0.0f);
            tloading.pos += tloading.rot * new Vector3(0.0f, 0.0f, loadingScreenDistance);

            var t = loadingScreenTransform != null ? loadingScreenTransform : transform;
            t.position = tloading.pos;
            t.rotation = tloading.rot;
        }

        _active = this;

        SteamVR_Events.Loading.Send(true);

        // Calculate rate for fading in loading screen and progress bar.
        if (loadingScreenFadeInTime > 0.0f)
        {
            fadeRate = 1.0f / loadingScreenFadeInTime;
        }
        else
        {
            alpha = 1.0f;
        }

        var overlay = OpenVR.Overlay;

        // Optionally create our loading screen overlay.
        if (loadingScreen != null && overlay != null)
        {
            loadingScreenOverlayHandle = GetOverlayHandle("loadingScreen", loadingScreenTransform != null ? loadingScreenTransform : transform, loadingScreenWidthInMeters);
            if (loadingScreenOverlayHandle != OpenVR.k_ulOverlayHandleInvalid)
            {
                var texture = new Texture_t();
                texture.handle      = loadingScreen.GetNativeTexturePtr();
                texture.eType       = SteamVR.instance.textureType;
                texture.eColorSpace = EColorSpace.Auto;
                overlay.SetOverlayTexture(loadingScreenOverlayHandle, ref texture);
            }
        }

        bool fadedForeground = false;

        // Fade out to compositor
        SteamVR_Events.LoadingFadeOut.Send(fadeOutTime);

        // Optionally set a skybox to use as a backdrop in the compositor.
        var compositor = OpenVR.Compositor;

        if (compositor != null)
        {
            if (front != null)
            {
                SteamVR_Skybox.SetOverride(front, back, left, right, top, bottom);

                // Explicitly fade to the compositor since loading will cause us to stop rendering.
                compositor.FadeGrid(fadeOutTime, true);
                yield return(new WaitForSeconds(fadeOutTime));
            }
            else if (backgroundColor != Color.clear)
            {
                // Otherwise, use the specified background color.
                if (showGrid)
                {
                    // Set compositor background color immediately, and start fading to it.
                    compositor.FadeToColor(0.0f, backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a, true);
                    compositor.FadeGrid(fadeOutTime, true);
                    yield return(new WaitForSeconds(fadeOutTime));
                }
                else
                {
                    // Fade the foreground color in (which will blend on top of the scene), and then cut to the compositor.
                    compositor.FadeToColor(fadeOutTime, backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a, false);
                    yield return(new WaitForSeconds(fadeOutTime + 0.1f));

                    compositor.FadeGrid(0.0f, true);
                    fadedForeground = true;
                }
            }
        }

        // Now that we're fully faded out, we can stop submitting frames to the compositor.
        SteamVR_Render.pauseRendering = true;

        // Continue waiting for the overlays to fully fade in before continuing.
        while (alpha < 1.0f)
        {
            yield return(null);
        }

        // Keep us from getting destroyed when loading the new level, otherwise this coroutine will get stopped prematurely.
        transform.parent = null;
        DontDestroyOnLoad(gameObject);

        if (!string.IsNullOrEmpty(internalProcessPath))
        {
            Debug.Log("Launching external application...");
            var applications = OpenVR.Applications;
            if (applications == null)
            {
                Debug.Log("Failed to get OpenVR.Applications interface!");
            }
            else
            {
                var workingDirectory = Directory.GetCurrentDirectory();
                var fullPath         = Path.Combine(workingDirectory, internalProcessPath);
                Debug.Log("LaunchingInternalProcess");
                Debug.Log("ExternalAppPath = " + internalProcessPath);
                Debug.Log("FullPath = " + fullPath);
                Debug.Log("ExternalAppArgs = " + internalProcessArgs);
                Debug.Log("WorkingDirectory = " + workingDirectory);
                var error = applications.LaunchInternalProcess(fullPath, internalProcessArgs, workingDirectory);
                Debug.Log("LaunchInternalProcessError: " + error);
#if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
#elif !UNITY_METRO
                System.Diagnostics.Process.GetCurrentProcess().Kill();
#endif
            }
        }
        else
        {
            var mode = loadAdditive ? UnityEngine.SceneManagement.LoadSceneMode.Additive : UnityEngine.SceneManagement.LoadSceneMode.Single;
            if (loadAsync)
            {
                Application.backgroundLoadingPriority = ThreadPriority.Low;
                async = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(levelName, mode);

                // Performing this in a while loop instead seems to help smooth things out.
                //yield return async;
                while (!async.isDone)
                {
                    yield return(null);
                }
            }
            else
            {
                UnityEngine.SceneManagement.SceneManager.LoadScene(levelName, mode);
            }
        }

        yield return(null);

        System.GC.Collect();

        yield return(null);

        Shader.WarmupAllShaders();

        // Optionally wait a short period of time after loading everything back in, but before we start rendering again
        // in order to give everything a change to settle down to avoid any hitching at the start of the new level.
        yield return(new WaitForSeconds(postLoadSettleTime));

        SteamVR_Render.pauseRendering = false;

        // Fade out loading screen.
        if (loadingScreenFadeOutTime > 0.0f)
        {
            fadeRate = -1.0f / loadingScreenFadeOutTime;
        }
        else
        {
            alpha = 0.0f;
        }

        // Fade out to compositor
        SteamVR_Events.LoadingFadeIn.Send(fadeInTime);

        // Refresh compositor reference since loading scenes might have invalidated it.
        compositor = OpenVR.Compositor;
        if (compositor != null)
        {
            // Fade out foreground color if necessary.
            if (fadedForeground)
            {
                compositor.FadeGrid(0.0f, false);
                compositor.FadeToColor(fadeInTime, 0.0f, 0.0f, 0.0f, 0.0f, false);
                yield return(new WaitForSeconds(fadeInTime));
            }
            else
            {
                // Fade scene back in, and reset skybox once no longer visible.
                compositor.FadeGrid(fadeInTime, false);
                yield return(new WaitForSeconds(fadeInTime));

                if (front != null)
                {
                    SteamVR_Skybox.ClearOverride();
                }
            }
        }

        // Finally, stick around long enough for our overlays to fully fade out.
        while (alpha > 0.0f)
        {
            yield return(null);
        }

        if (overlay != null)
        {
            if (progressBarOverlayHandle != OpenVR.k_ulOverlayHandleInvalid)
            {
                overlay.HideOverlay(progressBarOverlayHandle);
            }
            if (loadingScreenOverlayHandle != OpenVR.k_ulOverlayHandleInvalid)
            {
                overlay.HideOverlay(loadingScreenOverlayHandle);
            }
        }

        Destroy(gameObject);

        _active = null;

        SteamVR_Events.Loading.Send(false);
    }
Esempio n. 33
0
 /// <summary>
 /// Returns the next asynchronous operation to schedule.
 /// </summary>
 /// <param name="ops">Operations that can be scheduled.</param>
 /// <param name="current">The currently scheduled operation.</param>
 /// <param name="isYielding">True if the current operation is yielding, else false.</param>
 /// <param name="next">The next operation to schedule.</param>
 /// <returns>True if there is a next choice, else false.</returns>
 internal abstract bool GetNextOperation(IEnumerable <AsyncOperation> ops, AsyncOperation current,
                                         bool isYielding, out AsyncOperation next);
Esempio n. 34
0
        /// <summary>
        /// Start loading next scene
        /// </summary>
        /// <param name="isRestrat">is restart</param>
        /// <returns>IEnumerator</returns>
        // -------------------------------------------------------------------------------------------------------
        protected IEnumerator startNowLoadings(bool isRestrat)
        {
            yield return(null);

            // clear error
            {
                this.setError(null);
            }

            // wait by lock
            {
                int i = 0;

                while (this.m_lockBeforeLoadings.Count > 0)
                {
                    yield return(null);

                    for (i = this.m_lockBeforeLoadings.Count - 1; i >= 0; i--)
                    {
                        if (!this.m_lockBeforeLoadings[i])
                        {
                            this.m_lockBeforeLoadings.RemoveAt(i);
                        }
                    }
                }
            }

            // unload
            if (!isRestrat)
            {
                AsyncOperation ao = Resources.UnloadUnusedAssets();

                while (!ao.isDone)
                {
                    yield return(null);
                }

                System.GC.Collect();
            }

            // setSceneChangeState
            {
                if (!isRestrat)
                {
                    this.setSceneChangeState(SceneChangeState.StateEnum.NowLoadingMain);
                }
            }

            // CanStreamedLevelBeLoaded
            {
                if (!Application.CanStreamedLevelBeLoaded(this.m_nowLoadingSceneName))
                {
#if UNITY_EDITOR
                    Debug.LogWarning("(#if UNITY_EDITOR) Not found scene in BuildSettings : " + this.m_nowLoadingSceneName);
#endif
                    Invoke("showBackToTitleOkDialog", 0.1f);
                    yield break;
                }
            }

            // load scene
            {
                if (!isRestrat)
                {
                    // loadSceneBase
                    {
                        yield return(this.loadSceneBase(progress => {
                            this.m_loadingSceneProgress = progress;
                        }));
                    }

                    this.m_loadingSceneProgress = 1.0f;
                }
            }

            // main
            {
                if (!this.hasError())
                {
                    yield return(IEnumeratorStartupManager.Instance.startIEnumerator(IEnumeratorStartupManager.BeforeAfter.Before));

                    if (IEnumeratorStartupManager.Instance.hasError())
                    {
                        this.setError(IEnumeratorStartupManager.Instance.createErrorMessage());
                    }
                }

                if (!this.hasError())
                {
                    yield return(AssetBundleStartupManager.Instance.startAbStartup());

                    if (AssetBundleStartupManager.Instance.hasError())
                    {
                        this.setError(AssetBundleStartupManager.Instance.createErrorMessage());
                    }
                }

                if (!this.hasError())
                {
                    yield return(WwwStartupManager.Instance.startWwwStartup());

                    if (WwwStartupManager.Instance.hasError())
                    {
                        this.setError(WwwStartupManager.Instance.createErrorMessage());
                    }
                }

                if (!this.hasError())
                {
                    yield return(IEnumeratorStartupManager.Instance.startIEnumerator(IEnumeratorStartupManager.BeforeAfter.After));

                    if (IEnumeratorStartupManager.Instance.hasError())
                    {
                        this.setError(IEnumeratorStartupManager.Instance.createErrorMessage());
                    }
                }
            }

            // hasError
            {
                if (this.hasError())
                {
                    DialogManager.Instance.showYesNoDialog(this.m_messagesForError, this.retry, this.showBackToTitleOkDialog);
                    yield break;
                }
            }

            // retry
            {
                if (IEnumeratorStartupManager.Instance.hasNotYetContent(IEnumeratorStartupManager.BeforeAfter.Before))
                {
                    Invoke("retry", 0.1f);
                    yield break;
                }

                if (AssetBundleStartupManager.Instance.hasNotYetContent())
                {
                    Invoke("retry", 0.1f);
                    yield break;
                }

                if (WwwStartupManager.Instance.hasNotYetContent())
                {
                    Invoke("retry", 0.1f);
                    yield break;
                }

                if (IEnumeratorStartupManager.Instance.hasNotYetContent(IEnumeratorStartupManager.BeforeAfter.After))
                {
                    Invoke("retry", 0.1f);
                    yield break;
                }
            }

            // checkIfNeedToReloadScene
            {
                if (AssetBundleStartupManager.Instance.checkIfNeedToReloadScene())
                {
                    Invoke("callbackForStartingNowLoading", 0.1f);
                    yield break;
                }
            }

            // SceneChangeStateWatcher
            {
                yield return(null);

                this.setSceneChangeState(SceneChangeState.StateEnum.AllStartupsDonePrev);
                yield return(null);

                this.setSceneChangeState(SceneChangeState.StateEnum.AllStartupsDone);
                yield return(null);

                this.setSceneChangeState(SceneChangeState.StateEnum.AllStartupsDoneNext);
                yield return(null);
            }

            // wait by lock
            {
                int i = 0;

                while (this.m_lockAfterLoadings.Count > 0)
                {
                    yield return(null);

                    for (i = this.m_lockAfterLoadings.Count - 1; i >= 0; i--)
                    {
                        if (!this.m_lockAfterLoadings[i])
                        {
                            this.m_lockAfterLoadings.RemoveAt(i);
                        }
                    }
                }
            }

            // setSceneChangeState
            {
                this.setSceneChangeState(SceneChangeState.StateEnum.NowLoadingOutro);
            }

            // show ui
            {
                UiManager.Instance.showUi(this.m_uiIdentifiersForNextSceneStart, true, false, 0, this.sendNowLoadingDoneSignal, null);
            }

            // clear
            {
                this.clearContentsAfterLoadingScene();
            }
        }
Esempio n. 35
0
 /// <summary>
 /// IrcClient used to connect to an IRC Server
 /// </summary>
 /// <param name="Server">IRC Server</param>
 /// <param name="Port">IRC Port (6667 if you are unsure)</param>
 public IrcClient(string Server, int Port)
 {
     op           = AsyncOperationManager.CreateOperation(null);
     this._server = Server;
     this._port   = Port;
 }
Esempio n. 36
0
		public void press()
		{
				int currentSceneIndex=SceneManager.GetActiveScene().buildIndex;
		string smallsec="ﺦﺒﻄﻤﻟﺍ";
		string smallsection="smallsection";
		string scenenum="scenenumber";
	   PlayerPrefs.SetString(smallsection,smallsec);
		PlayerPrefs.SetInt(scenenum,currentSceneIndex);
					conn= "URI=file:" +Application.dataPath+"/Plugins/grad.s3db";
        dbconn=(IDbConnection) new SqliteConnection(conn);
        dbconn.Open();
		
		IDbCommand dbcmd=dbconn.CreateCommand();
		IDbCommand dbcmd2=dbconn.CreateCommand();
		IDbCommand dbcmd3=dbconn.CreateCommand();
		IDbCommand dbcmd4=dbconn.CreateCommand();
		
		string sqlQuery="SELECT count(*) FROM kitchen" ;
		string sqlQuery2="SELECT * FROM kitchen ";
		string sqlQuery4="DELETE FROM usedscenes";
		dbcmd.CommandText=sqlQuery;
		dbcmd2.CommandText=sqlQuery2;
		dbcmd4.CommandText=sqlQuery4;
		dbcmd4.ExecuteNonQuery();
		count = Convert.ToInt32(dbcmd.ExecuteScalar());
		IDataReader reader=dbcmd2.ExecuteReader();
		
		
		while(reader.Read())
		{
			int idd = reader.GetInt32(0);
			firstlist.Add(idd);
		}
	
		 //  if (Instance == null)
      //  {
           DontDestroyOnLoad(this.gameObject);
            Instance = this;
			
			firstlist.Sort();
		
			int min0=firstlist[0];
			int max0=firstlist[firstlist.Count -1];
		
			max0=max0+1;
		int num=UnityEngine.Random.Range(min0,max0);
		usednumbers.Add(num);
		
		  string sqlQuery3="INSERT INTO usedscenes (id) VALUES "+"("+num+")";
		
		  dbcmd3.CommandText=sqlQuery3;
		  dbcmd3.ExecuteNonQuery();
		  startTime=Time.time;
			AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(num);
       // }
      /*  else if (Instance != this)
        {
            Destroy (gameObject);
        }
		*/
		}
Esempio n. 37
0
        [STAThread] // Added to support UX

        static void Main(string[] args)
        {
            CrmServiceClient service = null;

            try
            {
                service = SampleHelpers.Connect("Connect");
                if (service.IsReady)
                {
                    #region Sample Code
                    #region Set up
                    SetUpSample(service);
                    #endregion Set up
                    #region Demonstrate

                    // Get a system user to use as the sender.
                    var emailSenderRequest  = new WhoAmIRequest();
                    var emailSenderResponse =
                        service.Execute(emailSenderRequest) as WhoAmIResponse;

                    // Set trackingId for bulk mail request.
                    Guid trackingId = Guid.NewGuid();

                    var bulkMailRequest = new SendBulkMailRequest()
                    {
                        // Create a query expression for the bulk operation to use to retrieve
                        // the contacts in the email list.
                        Query = new QueryExpression()
                        {
                            EntityName = Contact.EntityLogicalName,
                            ColumnSet  = new ColumnSet(new String[] { "contactid" }),
                            Criteria   = new FilterExpression()
                            {
                                Conditions =
                                {
                                    new ConditionExpression("contactid", ConditionOperator.In, _contactsIds)
                                }
                            }
                        },
                        // Set the Sender.
                        Sender = new EntityReference(SystemUser.EntityLogicalName, emailSenderResponse.UserId),
                        // Set the RegardingId - this field is required.
                        //RegardingId = Guid.Empty,
                        //RegardingType = SystemUser.EntityLogicalName,

                        // Use a built-in Microsoft Dynamics CRM email template.
                        // NOTE: The email template's "template type" must match the type of
                        // customers in the email list.  Our list contains contacts, so our
                        // template must be for contacts.
                        TemplateId = new Guid("07B94C1D-C85F-492F-B120-F0A743C540E6"),
                        RequestId  = trackingId
                    };

                    // Execute the async bulk email request
                    var resp = (SendBulkMailResponse)
                               service.Execute(bulkMailRequest);

                    Console.WriteLine("  Sent Bulk Email.");
                    #endregion

                    #region Monitoring SendBulkEmail

                    Console.WriteLine();
                    Console.WriteLine("Starting monitoring process..");

                    // Now that we've executed the bulk operation, we need to retrieve it
                    // using our tracking Id.

                    var bulkQuery = new QueryByAttribute()
                    {
                        EntityName = AsyncOperation.EntityLogicalName,
                        ColumnSet  = new ColumnSet(new string[] { "requestid" }),
                        Attributes = { "requestid" },
                        Values     = { trackingId }
                    };


                    // Retrieve the bulk email async operation.
                    EntityCollection aResponse = service.RetrieveMultiple(bulkQuery);


                    Console.WriteLine("  Retrieved Bulk Email Async Operation.");

                    // Monitor the async operation via polling.
                    int secondsTicker = ARBITRARY_MAX_POLLING_TIME;

                    AsyncOperation createdBulkMailOperation = null;

                    Console.WriteLine("  Checking operation's state for " + ARBITRARY_MAX_POLLING_TIME + " seconds.");
                    Console.WriteLine();

                    while (secondsTicker > 0)
                    {
                        // Make sure the async operation was retrieved.
                        if (aResponse.Entities.Count > 0)
                        {
                            // Grab the one bulk operation that has been created.
                            createdBulkMailOperation = (AsyncOperation)aResponse.Entities[0];

                            // Check the operation's state.
                            if (createdBulkMailOperation.StateCode.Value !=
                                AsyncOperationState.Completed)
                            {
                                // The operation has not yet completed.
                                // Wait a second for the status to change.
                                System.Threading.Thread.Sleep(1000);
                                secondsTicker--;

                                // Retrieve a fresh version the bulk delete operation.
                                aResponse = service.RetrieveMultiple(bulkQuery);
                            }
                            else
                            {
                                // Stop polling because the operation's state is now complete.
                                secondsTicker = 0;
                            }
                        }
                        else
                        {
                            // Wait a second for the async operation to activate.
                            System.Threading.Thread.Sleep(1000);
                            secondsTicker--;

                            // Retrieve the entity again
                            aResponse = service.RetrieveMultiple(bulkQuery);
                        }
                    }

                    // When the bulk email operation has completed, all sent emails will
                    // have a status of "Pending Send" and will be picked up by your email
                    // router.  Alternatively, you can then use BackgroundSendEmail to download
                    // all the emails created with the SendBulkEmail message.
                    // See the BackgroundSendEmail sample for an example.
                    #endregion

                    #region Check success

                    // Validate async operation succeeded
                    if (createdBulkMailOperation.StateCode.Value == AsyncOperationState.Completed)
                    {
                        Console.WriteLine("Operation Completed.");
                    }
                    else
                    {
                        Console.WriteLine("Operation not completed yet.");
                    }


                    #region Clean up
                    CleanUpSample(service);
                    #endregion Clean up
                }
                #endregion Demonstrate
                #endregion Sample Code

                else
                {
                    const string UNABLE_TO_LOGIN_ERROR = "Unable to Login to Common Data Service";
                    if (service.LastCrmError.Equals(UNABLE_TO_LOGIN_ERROR))
                    {
                        Console.WriteLine("Check the connection string values in cds/App.config.");
                        throw new Exception(service.LastCrmError);
                    }
                    else
                    {
                        throw service.LastCrmException;
                    }
                }
            }

            catch (Exception ex)
            {
                SampleHelpers.HandleException(ex);
            }

            finally
            {
                if (service != null)
                {
                    service.Dispose();
                }

                Console.WriteLine("Press <Enter> to exit.");
                Console.ReadLine();
            }
        }
Esempio n. 38
0
 /// <summary>
 /// Async level loading
 /// </summary>
 /// <param name="levelName"></param>
 /// <returns></returns>
 private IEnumerator LoadLevel(string levelName)
 {
     _async = SceneManager.LoadSceneAsync(levelName);
     yield return(_async);
 }
    IEnumerator LoadLevelWithRealProgress(string name)
    {
        //print("4");

        yield return(new WaitForSeconds(1));

        ao = SceneManager.LoadSceneAsync(name);
        ao.allowSceneActivation = false;

        while (!ao.isDone)
        {
            progressBar.value = ao.progress;

            if (ao.progress == 0.9f)
            {
                progressBar.value = 1.0f;

                if (LoadImmediately)
                {
                    //TouchButton.GetComponent<Button>().interactable = false;
                    if (MainMenuController.instance != null)
                    {
                        StartCoroutine(MainMenuController.instance.BeginFade(true, 1.5f));
                    }
                    else if (LevelSelectSceneController.instance != null)
                    {
                        StartCoroutine(LevelSelectSceneController.instance.BeginFade(true, 1.5f));
                    }
                    else if (GameSceneControllerLevel.instance != null)
                    {
                        StartCoroutine(GameSceneControllerLevel.instance.BeginFade(true, 1.5f));
                    }
                    else if (SurvivalLevelSelectSceneController.instance != null)
                    {
                        StartCoroutine(SurvivalLevelSelectSceneController.instance.BeginFade(true, 1.5f));
                    }
                    else if (WorldSceneController.instance != null)
                    {
                        StartCoroutine(WorldSceneController.instance.BeginFade(true, 1.5f));
                    }
                }
                else
                {
                    //LoadingSprite.SetActive(false);
                    //tapToStartSprite.SetActive(true);
                    //TouchButton.GetComponent<Button>().interactable = true;
                }



                //if (Input.GetKeyDown(KeyCode.F))
                //if(Input.GetTouch(0).phase == TouchPhase.Began)
                //{
                //print("TOUCHED");


                //float fadeTime = fader.GetComponent<Fading>().BeginFade(1);
                //yield return new WaitForSeconds(fadeTime);

                //MainMenuController.instance.BeginFade();

                //

                //GameSceneController.instance.RestartGame();

                //GoToLevel(name);

                //}
            }

            //print(ao.progress);
            yield return(null);
        }

        print("End");
    }
 public WaitForAsyncOperation(AsyncOperation asyncOp)
 {
     this.asyncOp = asyncOp;
 }
Esempio n. 41
0
 /// <summary>
 /// Returns the next boolean choice.
 /// </summary>
 /// <param name="current">The currently scheduled operation.</param>
 /// <param name="maxValue">The max value.</param>
 /// <param name="next">The next boolean choice.</param>
 /// <returns>True if there is a next choice, else false.</returns>
 internal abstract bool GetNextBooleanChoice(AsyncOperation current, int maxValue, out bool next);
Esempio n. 42
0
 public static void StartLoadingScene()
 {
     SceneAsyncOperation = SceneManager.LoadSceneAsync(SceneName);
     SceneAsyncOperation.allowSceneActivation = false;
 }
 IEnumerator UnloadScene()
 {
     AsyncOperation operation = SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene().buildIndex);
     yield return null;
 }
Esempio n. 44
0
    public override bool Update()
    {
#if UNITY_EDITOR
        if (AssetBundleLoadManager.SimulateAssetBundleInEditor)
        {
            string[] levelPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(m_AssetBundleName, m_AssetName);
            if (levelPaths.Length == 0)
            {
                ///@TODO: The error needs to differentiate that an asset bundle name doesn't exist
                //        from that there right scene does not exist in the asset bundle...

                Debug.LogError("There is no scene with name \"" + m_AssetName + "\" in " + m_AssetBundleName);
                return(true);
            }


            if (m_IsAdditive)
            {
                m_Request = EditorApplication.LoadLevelAdditiveAsyncInPlayMode(levelPaths[0]);
            }
            else
            {
                m_Request = EditorApplication.LoadLevelAsyncInPlayMode(levelPaths[0]);
            }

            m_IsDone = true;
            DoCallback();
            return(false);
        }
#endif



        if (m_Request != null && m_Request.isDone)
        {
            m_IsDone = true;
            DoCallback();
            return(false);
        }
        else if (m_Request != null && !m_Request.isDone)
        {
            return(true);
        }

        LoadedAssetBundle bundle = AssetBundleLoadManager.Instance.GetLoadedAssetBundle(m_AssetBundleName, out m_DownloadingError);
        if (bundle != null)
        {
            if (m_IsAdditive)
            {
                m_Request = Application.LoadLevelAdditiveAsync(m_AssetName);
            }
            else
            {
                m_Request = Application.LoadLevelAsync(m_AssetName);
            }
            return(true);
        }
        else
        {
            return(true);
        }
    }
Esempio n. 45
0
 /// <inheritdoc/>
 public bool GetNextOperation(IEnumerable <AsyncOperation> ops, AsyncOperation current, bool isYielding, out AsyncOperation next)
 {
     if (this.PrefixStrategy.HasReachedMaxSchedulingSteps())
     {
         return(this.SuffixStrategy.GetNextOperation(ops, current, isYielding, out next));
     }
     else
     {
         return(this.PrefixStrategy.GetNextOperation(ops, current, isYielding, out next));
     }
 }
Esempio n. 46
0
 private void Start()
 {
     aLoadScene = SceneManager.LoadSceneAsync(mainScene);
     aLoadScene.allowSceneActivation = false;
 }
Esempio n. 47
0
    public IEnumerator End()
    {
        bool victory = true;

        if (!Input.GetKey(KeyCode.C))
        {
            for (int i = 0; i < Map.m.tower_fabs.Length + 1; i++)
            {
                if (Map.m.sectors[i].color != Sector.BlockColor.Cyan)
                {
                    victory = false;
                    break;
                }
            }
        }

        AsyncOperation o = null;

        if (!victory)
        {
            o = Application.LoadLevelAsync("scene_garage");
            o.allowSceneActivation = false;
        }

        GameObject p = Chassis.c.gameObject;

        while (p.transform.position.z > -200f)
        {
            p.transform.position += new Vector3(0f, 0f, -100f * Time.deltaTime);
            aud.volume           -= Time.deltaTime * 0.5f;
            yield return(null);
        }

        // Do clean up or anything else HERE

        // Unlocked a weapon!?
        if (GarageController.selected_sector.weapon_unlock >= 0)
        {
            GarageController.UnlockWeapon(GarageController.selected_sector.weapon_unlock);
        }

        // Won with a new weapon!?
        bool save_settings = false;

        for (int i = 0; i < GarageController.weapons.Length; i++)
        {
            if ((Chassis.c.sc_class_1 && Chassis.c.fore != null &&
                 Chassis.c.fore.weapon_name.Equals(GarageController.weapons[i].weapon_name))
                ||
                (Chassis.c.sc_class_2 && Chassis.c.turret != null &&
                 Chassis.c.turret.weapon_name.Equals(GarageController.weapons[i].weapon_name)))
            {
                Settings.won_with_which_weapons[i] = true;

                bool unlocked_jack_achieve = true;
                for (int j = 0; j < Settings.won_with_which_weapons.Length; j++)
                {
                    if (!Settings.won_with_which_weapons[j])
                    {
                        unlocked_jack_achieve = false;
                        j = Settings.won_with_which_weapons.Length;
                    }
                }
                if (unlocked_jack_achieve)
                {
                    Utilities.u.UnlockAchievement("Jack of All Guns");
                }
                save_settings = true;
            }
        }

        if (save_settings)
        {
            Settings.SaveSettings();
        }
        // Okay clean up is all done.

        if (!victory)
        {
            o.allowSceneActivation = true;
            while (!o.isDone)
            {
                yield return(true);
            }

            p.transform.position = Vector3.zero;
            p.transform.rotation = Quaternion.identity;
        }
        else
        {
            //Achievement
            Utilities.u.UnlockAchievement("Golden Chariot");

            Destroy(Chassis.c.gameObject);
            Destroy(Map.m);

            Application.LoadLevelAsync("scene_victory");
        }

        Destroy(gameObject);
    }
Esempio n. 48
0
 public void StartLoadScene(MonoBehaviour mono, AsyncOperation async)
 {
     asyncOperation = async;
     mono.StartCoroutine(LoadingScene());
 }
Esempio n. 49
0
        /// <summary>
        /// Alternate keys may not be active immediately after a solution defining them is installed.
        /// This method polls the metadata for a specific entity
        /// to delay execution of the rest of the sample until the alternate keys are ready.
        /// </summary>
        /// <param name="service">Specifies the service to connect to.</param>
        /// <param name="asyncJob">The system job that creates the index to support the alternate key</param>
        /// <param name="iteration">The number of times this method has been called.</param>
        ///
        private static bool VerifyBookCodeKeyIsActive(IOrganizationService service, EntityReference asyncJob = null, int iteration = 0)
        {
            if (iteration > 5)
            {
                //Give up
                return(false);
            }


            if (iteration == 0) //only the first time
            {
                //Get whether the Entity Key index is active from the metadata
                EntityQueryExpression entityQuery = new EntityQueryExpression();
                entityQuery.Criteria = new MetadataFilterExpression(LogicalOperator.And)
                {
                    Conditions = { { new MetadataConditionExpression("LogicalName", MetadataConditionOperator.Equals, "sample_book") } }
                };

                entityQuery.Properties = new MetadataPropertiesExpression("Keys");

                RetrieveMetadataChangesRequest metadataRequest = new RetrieveMetadataChangesRequest()
                {
                    Query = entityQuery
                };
                RetrieveMetadataChangesResponse metadataResponse = (RetrieveMetadataChangesResponse)service.Execute(metadataRequest);
                EntityKeyMetadata bookcodekey = metadataResponse.EntityMetadata.FirstOrDefault().Keys.FirstOrDefault();

                if (bookcodekey.EntityKeyIndexStatus == EntityKeyIndexStatus.Active)
                {
                    return(true);
                }
                else
                {
                    iteration++;
                    return(VerifyBookCodeKeyIsActive(service, bookcodekey.AsyncJob, iteration));
                }
            }
            else
            {
                //Check the status of the system job that is should indicate that the alternate key index is active.
                AsyncOperation systemJob = (AsyncOperation)service.Retrieve(asyncJob.LogicalName, asyncJob.Id, new ColumnSet("statecode", "statuscode"));

                if (systemJob.StateCode == AsyncOperationState.Completed) //Completed
                {
                    if (!systemJob.StatusCode.Value.Equals(30))           //Not Succeeded
                    {
                        //Delete the system job and try to reactivate
                        service.Delete(asyncJob.LogicalName, asyncJob.Id);

                        ReactivateEntityKeyRequest reactivateRequest = new ReactivateEntityKeyRequest()
                        {
                            EntityLogicalName    = "sample_book",
                            EntityKeyLogicalName = "sample_bookcode"
                        };
                        ReactivateEntityKeyResponse reactivateResponse = (ReactivateEntityKeyResponse)service.Execute(reactivateRequest);

                        //Get the system job created by the reactivate request
                        QueryByAttribute systemJobQuery = new QueryByAttribute("asyncoperation");
                        systemJobQuery.AddAttributeValue("primaryentitytype", "sample_book");
                        systemJobQuery.AddOrder("createdon", OrderType.Descending);
                        systemJobQuery.TopCount  = 1;
                        systemJobQuery.ColumnSet = new ColumnSet("asyncoperationid", "name");

                        EntityCollection systemJobs = service.RetrieveMultiple(systemJobQuery);
                        asyncJob = systemJobs.Entities.FirstOrDefault().ToEntityReference();

                        iteration++;
                        return(VerifyBookCodeKeyIsActive(service, asyncJob, iteration));
                    }
                    else
                    {
                        //It succeeded
                        return(true);
                    }
                }
                else
                {
                    //Give it more time to complete
                    Thread.Sleep(TimeSpan.FromSeconds(30));
                    iteration++;
                    return(VerifyBookCodeKeyIsActive(service, asyncJob, iteration));
                }
            }
        }
Esempio n. 50
0
            internal void OpenNextPresent(Type presentType, LoadRuleData rule, object openArg, Action callback)
            {
                if (null == rule)
                {
                    rule = Present.DefaultLoadRule;
                }

#if LOG_DEBUG
                Debug.Log(string.Format("PRESENT<{0}={1:X8}>:NEXT:{2}, RULE:{3}, ARG:{4}, CB:{5}, STACK_TRACE:\n{6}",
                                        this.CurrentPresentName,
                                        (uint)this.CurrentPresentHashCode,
                                        null != presentType ? presentType.Name : "null",
                                        rule,
                                        openArg,
                                        callback,
                                        new System.Diagnostics.StackTrace(true).ToString()));
#endif// LOG_DEBUG
#if LOG_MEMORY
                var stateOfPresent = null != this.loadedPresent ? this.loadedPresent.GetState() : -1;
                Debug.Log(string.Format("APP:{0}, {1}, {2}",
                                        DebugImpl.CreateUptimeChunk(),
                                        DebugImpl.CreatePresentChunk("AT", presentType, -1),
                                        DebugImpl.CreatePresentChunk("EVENT:SET_PRESENT_PREV", this.presentType, stateOfPresent)));
#endif// LOG_MEMORY

                this.ClosePresent(presentType);

                if (null != this.asyncOperFakeOpenForGarbageCollect || null != this.asyncOper || this.fastOpenWait)
                {
#if LOG_DEBUG
                    Debug.Log(string.Format("PRESENT<{0}={1:X8}>:NEXT_DUPLICATED:{2}",
                                            this.CurrentPresentName,
                                            (uint)this.CurrentPresentHashCode,
                                            null != presentType ? presentType.Name : "null"));
#endif// LOG_DEBUG
                    this.OpenPresentWait(presentType, rule, openArg, callback);
                    return;
                }
                else if (null != this.wait)
                {
                    Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:NEXT_DUPLICATED_EXCEPTION#2:{2}, RULE:{3}, ARG:{4}, CB{5}, WAIT:{6}, CURRENT:{7}",
                                                 this.CurrentPresentName,
                                                 (uint)this.CurrentPresentHashCode,
                                                 null != presentType ? presentType.Name : "null",
                                                 rule,
                                                 openArg,
                                                 callback,
                                                 this.wait,
                                                 this.presentType));
                    return;
                }

                this.presentTypePrev = this.presentType;
                this.presentType     = presentType;

                this.openArg = openArg;

                this.openCallback = callback;
                this.isChanging   = true;

                Preference.Save();
                this.preloadPresent = (Present)Activator.CreateInstance(this.presentType);
#if LOG_DEBUG
                Debug.Log(string.Format("PRESENT<{0}={1:X8}>:CREATE_INSTANCE:<{2}={3:X8}>",
                                        this.CurrentPresentName,
                                        (uint)this.CurrentPresentHashCode,
                                        null != this.preloadPresent ? this.preloadPresent.GetType().Name : "null",
                                        null != this.preloadPresent ? (uint)this.preloadPresent.GetHashCode() : 0u));
#endif// LOG_DEBUG
                try
                {
                    this.preloadPresent.OnPreloading();
                }
                catch (Exception e)
                {
                    Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:LOAD_EXCEPT:{2}",
                                                 this.CurrentPresentName,
                                                 (uint)this.CurrentPresentHashCode,
                                                 e));
                }

                switch (rule.Rule)
                {
                case LoadRule.FlushGarbage:
                    this.asyncOperFakeOpenForGarbageCollect = SceneManager.LoadSceneAsync("Next");
                    break;

                case LoadRule.Direct:
                    if (this.preloadPresent.DoOpen)
                    {
                        this.asyncOper = SceneManager.LoadSceneAsync(this.presentType.Name);
                    }
                    else
                    {
                        this.fastOpenWait = true;
                    }
                    break;

                case LoadRule.PreloadedScene:
                    this.asyncOper = rule.Preloaded;
                    break;
                }
            }
 public override void OnEnter()
 {
     _op = Resources.UnloadUnusedAssets();
 }
Esempio n. 52
0
    IEnumerator loadScene()
    {
        AsyncOperation async = Application.LoadLevelAsync(2);

        yield return(async);
    }
Esempio n. 53
0
 public IEnumerator LoadLevel(string nameScene)
 {
     ao = SceneManager.LoadSceneAsync(nameScene);
     ao.allowSceneActivation = true;
     yield return(new WaitForEndOfFrame());
 }
Esempio n. 54
0
 private void SceneLoadOnCompleted(AsyncOperation obj)
 {
     Debug.Log("Scene load completed.");
 }
    IEnumerator LoadSceneAsync(string loadSceneName, AssetBundle depBundle)
    {
        AsyncOperation async = SceneManager.LoadSceneAsync(loadSceneName, LoadSceneMode.Single);

        yield return(async);
    }
Esempio n. 56
0
            internal void UpdatePresent()
            {
                if (this.isResumeStart)
                {
                    this.isSuspended   = false;
                    this.isResumeStart = false;

                    if (null != this.loadedPresent)
                    {
                        try
                        {
                            if (this.loadedPresent.isPresentSuspended)
                            {
                                this.loadedPresent.isPresentSuspended = false;
                                this.loadedPresent.OnResume();
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:ONRESUME_EXCEPT:{2}",
                                                         this.CurrentPresentName,
                                                         (uint)this.CurrentPresentHashCode,
                                                         e));
                        }
                    }
                }
                else if (this.isSuspended)
                {
                    return;
                }



                var loaded = false;

                if (null != this.preloadPresent)
                {
                    if (this.fastOpenWait)
                    {
                        if (this.preloadPresent.DoOpen)
                        {
                            this.fastOpenWait = false;
                            this.asyncOper    = SceneManager.LoadSceneAsync(this.presentType.Name);
                        }
                        else
                        {
                            return;
                        }
                    }
                    else if (null != this.asyncOperFakeOpenForGarbageCollect)
                    {
                        if (this.asyncOperFakeOpenForGarbageCollect.isDone && this.preloadPresent.DoOpen)
                        {
                            this.asyncOperFakeOpenForGarbageCollect = null;
                            this.asyncOper = SceneManager.LoadSceneAsync(this.presentType.Name);
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (null != this.asyncOper)
                    {
                        if (!this.asyncOper.allowSceneActivation)
                        {
                            this.asyncOper.allowSceneActivation = true;
                        }

                        if (!this.asyncOper.isDone)
                        {
                            this.preloadPresent.loadingProgress = this.asyncOper.progress;
                            return;
                        }

                        this.asyncOper = null;
                        this.OpenPresent();

                        loaded = true;
                    }
                }

                if (loaded)
                {
                    var openCallback = this.openCallback;
                    this.openCallback = null;
                    if (null != openCallback)
                    {
                        openCallback();
                    }

                    if (null != this.openListener)
                    {
                        this.openListener();
                    }

                    this.isChanging = false;
                }

                if (null != this.loadedPresent)
                {
                    try
                    {
                        this.loadedPresent.OnUpdate();
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:ONUPDATE_EXCEPT:{2}",
                                                     this.CurrentPresentName,
                                                     (uint)this.CurrentPresentHashCode,
                                                     e));
                    }

                    var fsm = this.loadedPresent.fsm;
                    if (fsm.HasStateTasks())
                    {
                        try
                        {
                            fsm.RunStateTasks();
                        }
                        catch (Exception e)
                        {
                            Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:STATETASK_EXCEPT:{2}",
                                                         this.CurrentPresentName,
                                                         (uint)this.CurrentPresentHashCode,
                                                         e));
                        }
                    }

                    if (fsm.HasTasks())
                    {
                        try
                        {
                            fsm.RunTasks();
                        }
                        catch (Exception e)
                        {
                            Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:TASK_EXCEPT:{2}",
                                                         this.CurrentPresentName,
                                                         (uint)this.CurrentPresentHashCode,
                                                         e));
                        }
                    }
                }

                if (loaded)
                {
                    if (null != this.wait)
                    {
                        var w = this.wait;
                        this.wait = null;
                        this.OpenNextPresent(w.PresentType, w.Rule, w.OpenArg, w.Callback);
                    }
                }

                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    this.Back();
                }
            }
        void CreateOperationOnCompleted(AsyncOperation obj)
        {
            if (m_CurrentRequest == null)
            {
                //If we lost our m_CurrentRequest request reference, we can't risk doing anything.
                return;
            }

            if (m_CurrentRequest.result != UnityWebRequest.Result.ProtocolError)
            {
                var jsonParser = new JSONParser(m_CurrentRequest.downloadHandler.text);
                var json       = jsonParser.Parse();
                var abort      = false;
                try
                {
                    var projectInfo = ExtractProjectInfoFromJson(json);
                    try
                    {
                        ServicesRepository.DisableAllServices(shouldUpdateApiFlag: false);
                        //Only register before creation. Remove first in case it was already added.
                        //TODO: Review to avoid dependency on project refreshed
                        UnityConnect.instance.ProjectStateChanged -= OnProjectStateChangedAfterCreation;
                        UnityConnect.instance.ProjectStateChanged += OnProjectStateChangedAfterCreation;
                        BindProject(projectInfo);
                    }
                    catch (Exception ex)
                    {
                        if (exceptionCallback != null)
                        {
                            exceptionCallback.Invoke(ex);
                            abort = true;
                        }
                        else
                        {
                            //If there is no exception callback, we have to at least log it
                            Debug.LogException(ex);
                        }
                    }
                    if (!abort)
                    {
                        createButtonCallback?.Invoke(projectInfo);
                    }
                }
                finally
                {
                    m_CurrentRequest?.Dispose();
                    m_CurrentRequest = null;
                }
            }
            else if (m_CurrentRequest.responseCode == k_HttpStatusCodeUnprocessableEntity)
            {
                m_CurrentRequest?.Dispose();
                m_CurrentRequest = null;
                m_CreateIteration++;
                RequestCreateOperation();
            }
            else
            {
                try
                {
                    var ex = new UnityConnectWebRequestException(L10n.Tr(k_CouldNotCreateProjectMessage))
                    {
                        error           = m_CurrentRequest.error,
                        method          = m_CurrentRequest.method,
                        timeout         = m_CurrentRequest.timeout,
                        url             = m_CurrentRequest.url,
                        responseHeaders = m_CurrentRequest.GetResponseHeaders(),
                        responseCode    = m_CurrentRequest.responseCode,
                        isHttpError     = (m_CurrentRequest.result == UnityWebRequest.Result.ProtocolError),
                        isNetworkError  = (m_CurrentRequest.result == UnityWebRequest.Result.ConnectionError),
                    };
                    if (exceptionCallback != null)
                    {
                        exceptionCallback.Invoke(ex);
                    }
                    else
                    {
                        //If there is no exception callback, we have to at least log it
                        Debug.LogException(ex);
                    }
                }
                finally
                {
                    m_CurrentRequest?.Dispose();
                    m_CurrentRequest = null;
                }
            }
        }
Esempio n. 58
0
 public WaitForAsyncOperation(AsyncOperation operation, bool allowActivation = true)
 {
     _operation = operation;
     _operation.allowSceneActivation = allowActivation;
 }
Esempio n. 59
0
 /// <summary>
 /// Returns the next integer choice.
 /// </summary>
 /// <param name="current">The currently scheduled operation.</param>
 /// <param name="maxValue">The max value.</param>
 /// <param name="next">The next integer choice.</param>
 /// <returns>True if there is a next choice, else false.</returns>
 internal abstract bool GetNextIntegerChoice(AsyncOperation current, int maxValue, out int next);
Esempio n. 60
0
 public LoadRuleData(AsyncOperation preloaded)
 {
     this.rule           = LoadRule.PreloadedScene;
     this.preloadedScene = preloaded;
 }