Exemple #1
0
        /// <summary>
        /// 创建一个SceneTileWrapper
        /// </summary>
        public SceneTileWrapper Alloc(TileIndex rTileIndex, SceneTile rSceneTile, TerrainData rTerrainData)
        {
            Debug.Log("加载块: " + rTileIndex.ToString());

            var rSceneTileWrapper = new SceneTileWrapper();

            rSceneTileWrapper.curIndex = new TileIndex(rTileIndex);
            if (rSceneTile != null && rTerrainData != null)
            {
                rSceneTileWrapper.tileGo                    = Terrain.CreateTerrainGameObject(rTerrainData);
                rSceneTileWrapper.tileGo.name               = string.Format("tile_{0}_{1}", rTileIndex.Row, rTileIndex.Col);
                rSceneTileWrapper.tileGo.transform.parent   = mMultiSceneRootGo.transform;
                rSceneTileWrapper.tileGo.transform.position = new Vector3(rSceneTile.Offset.x, 0, rSceneTile.Offset.y);
                rSceneTileWrapper.sceneTile                 = rSceneTile;
            }
            mBlockBuffers.Add(rSceneTileWrapper);
            return(rSceneTileWrapper);
        }
Exemple #2
0
        /// <summary>
        /// 加载单个场景块
        /// </summary>
        public IEnumerator HandleRequest(SceneTileRequest rSceneTileRequest)
        {
            TileIndex rTileIndex = rSceneTileRequest.CurIndex;

            SceneTileWrapper rSceneTileWrapper = mSceneBlockBuffer.Get(rTileIndex);

            if (rSceneTileWrapper != null)
            {
                rSceneTileRequest.SceneTileWrapper = rSceneTileWrapper;
                rSceneTileWrapper.SetActive(true);
                rSceneTileRequest.IsRunning   = false;
                rSceneTileRequest.IsCompleted = true;
                mSceneBlockBuffer.SetActive(rTileIndex, true);
                yield break;
            }

            string rSceneTileConfigPath = string.Format("{0}/tile_{1}_{2}_config", MultiSceneManager.CurrentTestSceneName, rTileIndex.Row, rTileIndex.Col);
            string rSceneTilePath       = string.Format("{0}/tile_{1}_{2}", MultiSceneManager.CurrentTestSceneName, rTileIndex.Row, rTileIndex.Col);

            ResourceRequest rRequest = Resources.LoadAsync <SceneTile>(rSceneTileConfigPath);

            yield return(rRequest);

            SceneTile rSceneTile = rRequest.asset as SceneTile;

            ResourceRequest rDataRequest = Resources.LoadAsync <TerrainData>(rSceneTilePath);

            yield return(rDataRequest);

            TerrainData rTerrainData = rDataRequest.asset as TerrainData;

            rSceneTileWrapper = mSceneBlockBuffer.Alloc(rTileIndex, rSceneTile, rTerrainData);

            rSceneTileRequest.SceneTileWrapper = rSceneTileWrapper;
            rSceneTileRequest.IsRunning        = false;
            rSceneTileRequest.IsCompleted      = true;
        }