Пример #1
0
        public void LoadFloatFile(string filepath)
        {
            try
            {
                if (File.Exists(filepath))
                {
                    floatReader = new FloatReader();

                    floatReader.LoadFloatGrid(filepath);

                    if (floatReader.LoadComplet)
                    {
                        phase = GeneratingTerrainPhase.generateTerrains;

                        floatReader.LoadComplet = false;

                        if (floatReader.Terrain_Dimension.x == 0 || floatReader.Terrain_Dimension.y == 0)
                        {
                            Debug.LogError("Can't detecte terrain dimension please try againe .");
                            return;
                        }
                        else
                        {
                            prefs.terrainDimensions = new Vector2((float)floatReader.Terrain_Dimension.x, (float)floatReader.Terrain_Dimension.y);
                        }


                        if (floatReader.Tiles.x != 0 || floatReader.Tiles.y != 0)
                        {
                            prefs.terrainCount = new Vector2Int((int)floatReader.Tiles.x, (int)floatReader.Tiles.y);
                        }
                        else
                        {
                            Debug.LogError(floatReader.Tiles + "Terrain textures Tiles Count not set in Hdr file ... try againe");

                            phase = GeneratingTerrainPhase.idle;
                        }

                        if (OnProgression != null)
                        {
                            OnProgression("Loading Elevation File", 1);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Log("Couldn't convert Terrain file:");
                Debug.Log(ex.Message + Environment.NewLine);
                phase = GeneratingTerrainPhase.idle;
            };
        }