コード例 #1
0
    // Use this for initialization
    IEnumerator Start()
    {
        DontDestroyOnLoad(gameObject);
        yield return(new WaitForSeconds(2f));

        if (loadingPrefab)
        {
            GameObject go = (GameObject)Instantiate(loadingPrefab);

            m_sceneLoading = go.GetComponentInChildren <UnityEngine.UI.SceneLoading>();
            if (m_sceneLoading)
            {
                m_sceneLoading.transitionIn    = transitionIn;
                m_sceneLoading.transitionOut   = transitionOut;
                m_sceneLoading.transitionSpeed = transitionSpeed;

                m_sceneLoading.onTransitionInOver = delegate() {
                    StartCoroutine(ShowIcon());
                };
                m_sceneLoading.onLoadSceneComplete = delegate() {
                    StartCoroutine(RemoveIcon());
                };
                m_sceneLoading.StartTransitionIn(1);
            }
        }
    }
コード例 #2
0
ファイル: End.cs プロジェクト: LadySaturday/AidansApp
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         SceneLoading.SceneManageStatic("PossumRun_End");
     }
 }
コード例 #3
0
    // Start is called before the first frame update
    void Start()
    {
        animText    = startBut.GetComponent <Animator>();
        animScreens = screens.GetComponent <Animator>();
        sl          = GetComponent <SceneLoading>();

        loadingImage.gameObject.SetActive(false);
        progressText.gameObject.SetActive(false);
        loadingImagePr.gameObject.SetActive(false);
    }
コード例 #4
0
 static void OnInitialSceneLoaded(string scene, LoadSceneMode mode)
 {
     if (instance != null)
     {
         for (int i = 0; i < instance.initializationSceneNames.Length; i++)
         {
             SceneLoading.LoadSceneAsync(instance.initializationSceneNames[i], null, null, LoadSceneMode.Additive, false);
         }
     }
 }
コード例 #5
0
 public virtual void Awake()
 {
     if (Instance == null)
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
         return;
     }
     Destroy(gameObject);
 }
コード例 #6
0
        void Update()
        {
            if (GameManager.isPaused)
            {
                return;
            }
            if (GameManager.isInMainMenuScene)
            {
                return;
            }
            if (!GameManager.playerExists)
            {
                return;
            }
            if (!isInOpenWorldScene)
            {
                return;
            }

            Camera playerCamera = GameManager.playerCamera;

            if (playerCamera == null)
            {
                return;
            }

            #if UNITY_EDITOR
            CheckForDuplicateSceneLoad();
            #endif

            CheckLoadedScenes();

            Vector3    playerPosition = playerCamera.transform.position;
            Vector2Int playerCell     = GridManagement.CalculateGrid(playerPosition, settings.cellSize);

            int gridResolution = settings.gridResolution;

            playerCell.x = Mathf.Clamp(playerCell.x, 0, gridResolution - 1);
            playerCell.y = Mathf.Clamp(playerCell.y, 0, gridResolution - 1);

            string gridScene;
            if (GetCurrentGridScene(playerCell, 1, out gridScene))
            {
                SceneLoading.SetPlayerScene(gridScene);
            }
            else
            {
                // curernt grid scene is not loaded yet...
                LoadGridScene(playerCell, 0);
                LoadGridScene(playerCell, 1);
            }

            UpdateGrids(playerCell, gridResolution);
        }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        mInstance = this;

        if (SceneManager.GetActiveScene().name == "loading")
        {
            loadingSlider.value = 0.00f;
            //启动协程
            StartCoroutine(AsyncLoading());
        }
    }
コード例 #8
0
        void LoadGridScene(Vector2Int grid, int lod)
        {
            string sceneName = settings.Grid2Scene(grid, lod);

            if (!string.IsNullOrEmpty(sceneName))
            {
                if (!SceneLoading.IsSceneLoadingOrUnloading(sceneName))
                {
                    SceneLoading.LoadSceneAsync(sceneName, null, null, LoadSceneMode.Additive, false);
                }
            }
        }
コード例 #9
0
ファイル: GTLauncher.cs プロジェクト: zyb2013/GameProject3
    public void LoadScene(int sceneId, Callback finishCallback = null)
    {
        DCopy db = ReadCfgCopy.GetDataById(sceneId);

        this.NextCopyType = db.CopyType;
        CommandLoadScene cmd = new CommandLoadScene();

        cmd.SceneID = sceneId;
        SceneLoading s = (SceneLoading)mStateMachine.GetState(ECopyType.TYPE_LOAD);

        s.mCallback = finishCallback;
        ChangeState(ECopyType.TYPE_LOAD, cmd);
    }
コード例 #10
0
    private void Awake()
    {
        if (singleton && singleton != this)
        {
            Destroy(this);
        }
        else
        {
            singleton = this;
        }
        // DontDestroyOnLoad(gameObject);

        // sceneIndexToLoad = 2; // first scene to load is mainmenu
    }
コード例 #11
0
    private void CheckForSceneLoading(GameObject target)
    {
        SceneLoading sceneLoading = target.GetComponentInParent <SceneLoading>();

        if (sceneLoading != null)
        {
            if (sceneLoading.IsActive)
            {
                SceneHandler.Instance?.LoadScenes(sceneLoading.ScenesToLoad, sceneLoading.ActiveScene);
                SceneHandler.Instance?.SetLight(sceneLoading.ActivateDirectionalLight);
                SceneHandler.Instance?.SetFog(sceneLoading.ActivateFog);
            }
        }
    }
コード例 #12
0
 void UnloadNonNeighbors(Vector2Int playerGrid)
 {
     for (int i = 0; i < loadedWorldScenes.Count; i++)
     {
         WorldScene loadedScene = loadedWorldScenes[i];
         if (!SceneLoading.IsSceneLoadingOrUnloading(loadedScene.scene))
         {
             int dist = loadedScene.lod == 0 ? settings.lod0_distance : settings.lod1_distance;
             if (GridManagement.GridDistance(loadedScene.grid, playerGrid) > dist)
             {
                 SceneLoading.UnloadSceneAsync(loadedScene.scene);
             }
         }
     }
 }
コード例 #13
0
        // when we're entering the "open world" for the first time
        // we need to make sure the settings scene is laoded first and is the active scene,
        // in order to keep the lighting/ fog settings consistent for all loaded cell scenes...
        static bool OverrideSceneLoad(string scene, Action <LoadSceneMode> onSceneStartLoad, Action <string, LoadSceneMode> onSceneLoaded, LoadSceneMode loadSceneMode)
        {
            // check if it's an open world scene we're trying to load
            if (!scene.Contains(OpenWorld.openWorldSceneKey))
            {
                return(false);
            }
            // check if we're just additively loading the scene,
            // if we are, then let's assume the world is already loaded..
            if (loadSceneMode == LoadSceneMode.Additive)
            {
                return(false);
            }

            // else we're going into the "open world" for the first time

            // call this after we've finished loading the open world main scene
            Action <string, LoadSceneMode> onOpenWorldMainSceneLoaded = (s, m) => {
                Action <string, LoadSceneMode> onTargetSceneLoaded = (s2, m2) => {
                    SceneLoading.SetPlayerScene(s2);
                    if (onSceneLoaded != null)
                    {
                        onSceneLoaded(s2, m2);
                    }
                };

                // make sure lod0 and lod1 version are loaded.
                // it's assumed that if we're single loading the open world, we're moving the player there
                // so we make sure all lods are loaded, so we dotn accidentally fall trhough unloaded terrain
                // when unpausing after load...


                bool isLOD0 = scene.Contains(OpenWorld.lod0Check);

                string lod0Version = isLOD0 ? scene : settings.GetLOD0Version(scene);
                string lod1Version = !isLOD0 ? scene : settings.GetLOD1Version(scene);

                SceneLoading.LoadSceneAsync(lod0Version, null, null, LoadSceneMode.Additive, true);

                // fake single load, so game keeps paused / ui's still black out, etc...
                // use finished loading callbacks for lod1 version, so we dont accidentally fall through non loaded terrrain
                SceneLoading.LoadSceneAsync(lod1Version, null, onTargetSceneLoaded, LoadSceneMode.Additive, true);
            };

            SceneLoading.LoadSceneAsync(OpenWorld.openWorldSettingsScene, onSceneStartLoad, onOpenWorldMainSceneLoaded, LoadSceneMode.Single, false);

            return(true);
        }
コード例 #14
0
        protected override void Awake()
        {
            base.Awake();
            if (!thisInstanceErrored)
            {
                Application.backgroundLoadingPriority = ThreadPriority.Low;

                SceneManager.sceneLoaded   += OnSceneLoaded;
                SceneLoading.onSceneExit   += OnSceneExit;
                SceneLoading.onSceneUnload += OnSceneUnload;
                SceneLoading.SetSceneLoadOverride(OverrideSceneLoad);

                FastTravel.SetGetFastTravelDefaultPosition(GetFastTravelDefaultPosition);
                SaveObject.SetSaveObjectsSceneFilter(FilterSaveObjectsForScene);
            }
        }
コード例 #15
0
    private void Update()
    {
        if (run)
        {
            float step = 3 * Time.deltaTime;

            // move sprite towards the target location

            transform.position = Vector2.MoveTowards(transform.position, new Vector2(10, transform.position.y), step);

            if (transform.position.x == 10)
            {
                SceneLoading.SceneManageStatic("PossumRun");
            }
        }
    }
コード例 #16
0
ファイル: SceneManager.cs プロジェクト: ToufiqueAzad/FlaxAPI
        internal static void Internal_OnSceneEvent(SceneEventType eventType, Scene scene, ref Guid sceneId)
        {
            switch (eventType)
            {
            case SceneEventType.Saving:
                SceneSaving?.Invoke(scene, sceneId);
                break;

            case SceneEventType.Saved:
                SceneSaved?.Invoke(scene, sceneId);
                break;

            case SceneEventType.SaveError:
                SceneSaveError?.Invoke(scene, sceneId);
                break;

            case SceneEventType.Loading:
                SceneLoading?.Invoke(scene, sceneId);
                break;

            case SceneEventType.Loaded:
                SceneLoaded?.Invoke(scene, sceneId);
                break;

            case SceneEventType.LoadError:
                SceneLoadError?.Invoke(scene, sceneId);
                break;

            case SceneEventType.Unloading:
                SceneUnloading?.Invoke(scene, sceneId);
                break;

            case SceneEventType.Unloaded:
                SceneUnloaded?.Invoke(scene, sceneId);
                break;
            }
        }
コード例 #17
0
 public void OnSceneLoading(string value, float progress)
 {
     SceneLoading?.Invoke(value, progress);
 }
コード例 #18
0
ファイル: Level.cs プロジェクト: bshishov/LudumDare47
 private void Awake()
 {
     // Level requires UI
     SceneLoading.TryLoadSceneAdditive("UI");
 }
コード例 #19
0
ファイル: Scheduler.cs プロジェクト: 741645596/Golf
 public static void SetLoading(SceneLoading loading)
 {
     g_loading = loading;
 }
コード例 #20
0
 public static void LoadInitializationScene()
 {
     SceneLoading.LoadSceneAsync(mainInitializationScene, null, OnInitialSceneLoaded, LoadSceneMode.Single, false);
 }
コード例 #21
0
 // Use this for initialization
 void Start()
 {
     //每次回到选关都重新加载,避免之前修改残留(Load函数都已经加了重置
     SceneLoading.LoadBundle_PvE_Level();
 }
コード例 #22
0
 /// <summary>
 /// Raises the scene loading event.
 /// </summary>
 private void RaiseSceneLoadingEvent(string[] sceneName) =>
 SceneLoading?.Invoke(this, new SceneEventArgs(sceneName));
コード例 #23
0
 // Use this for initialization
 void Start()
 {
     sceneLoading = this.GetComponent <SceneLoading> ();
 }
コード例 #24
0
 // Start is called before the first frame update
 void Start()
 {
     _sl = new SceneLoading();
 }