Esempio n. 1
0
    //Кнопка: Загрузка с файла настроек
    private void LoadOption(bool key)
    {
        _firstload = false;
        if (key)
        {
            //Удалим все splatmap в окне перед загрузкой в это окно
            while (_splats.Count > 0)
            {
                _splats.RemoveAt(_splats.Count - 1);
            }
            while (_normals.Count > 0)
            {
                _normals.RemoveAt(_normals.Count - 1);
            }
            //Удалим все _trees в окне перед загрузкой в это окно
            while (_trees.Count > 0)
            {
                _trees.RemoveAt(_trees.Count - 1);
            }
            //Удалим все _grass в окне перед загрузкой в это окно
            while (_grass.Count > 0)
            {
                _grass.RemoveAt(_grass.Count - 1);
            }

            // Загрузка
            var textReader = new StreamReader(@"option.ini");

            while (textReader.Peek() != -1)
            {
                String line = textReader.ReadLine(); //Line = textReader.ReadToEnd();

                switch (line)
                {
                    case "<SplatMapInfo2>":

                        SplatMapInfo2 sp = new SplatMapInfo2();
                        sp.Texture = (Texture2D) AssetDatabase.LoadAssetAtPath(textReader.ReadLine(), typeof (Texture2D));
                        sp.Texture = (Texture2D) EditorGUILayout.ObjectField(sp.Texture, typeof (Texture2D), false);
                        sp.TileSizeX = Convert.ToInt32(textReader.ReadLine());
                        sp.TileSizeY = Convert.ToInt32(textReader.ReadLine());
                        sp.TileOffsetX = Convert.ToInt32(textReader.ReadLine());
                        sp.TileOffsetY = Convert.ToInt32(textReader.ReadLine());
                        sp.Filemask = textReader.ReadLine();
                        sp.FoldOutStat = true;
                        _splats.Add(sp);
                        _splatFoldout = true;
                        break;

                     case "<NormalMapInfo2>":

                        NormalMapInfo2 nm = new NormalMapInfo2();
                        nm.Texture = (Texture2D) AssetDatabase.LoadAssetAtPath(textReader.ReadLine(), typeof (Texture2D));
                        nm.Texture = (Texture2D) EditorGUILayout.ObjectField(nm.Texture, typeof (Texture2D), false);
                        nm.TileSizeX = Convert.ToInt32(textReader.ReadLine());
                        nm.TileSizeY = Convert.ToInt32(textReader.ReadLine());
                        nm.TileOffsetX = Convert.ToInt32(textReader.ReadLine());
                        nm.TileOffsetY = Convert.ToInt32(textReader.ReadLine());
                        nm.Filemask = textReader.ReadLine();
                        nm.FoldOutStat = true;
                        _normals.Add(nm);
                        _normalFoldout = true;
                        break;

                    case "<TreeMapInfo2>":

                      TreeMapInfo2 tm = new TreeMapInfo2();
                      tm.Prefab = (GameObject)AssetDatabase.LoadAssetAtPath(textReader.ReadLine(), typeof(GameObject));
                      tm.Prefab = (GameObject)EditorGUILayout.ObjectField(tm.Prefab, typeof(GameObject), false);
                      tm.BendFactor = Convert.ToInt32(textReader.ReadLine());
                      tm.ColorVariation = float.Parse(textReader.ReadLine());
                      tm.HeightScale = Convert.ToInt32(textReader.ReadLine());
                      tm.WidthScale = Convert.ToInt32(textReader.ReadLine());
                      tm.HeightVariation = Convert.ToInt32(textReader.ReadLine());
                      tm.WidthVariation = Convert.ToInt32(textReader.ReadLine());
                      tm.MaxDensity = float.Parse(textReader.ReadLine());
                      tm.Filemask = textReader.ReadLine();
                      tm.FoldOutStat = true;
                      _trees.Add(tm);
                      _treeFoldout = true;
                        break;

                    case "<GrassInfo2>":

                       GrassInfo2 gi = new GrassInfo2();
                       gi.Texture = (Texture2D) AssetDatabase.LoadAssetAtPath(textReader.ReadLine(), typeof (Texture2D));
                       gi.Texture = (Texture2D) EditorGUILayout.ObjectField(gi.Texture, typeof (Texture2D), false);
                       gi.MinWidth = float.Parse(textReader.ReadLine());
                       gi.MaxWidth = float.Parse(textReader.ReadLine());
                       gi.MinHeight = float.Parse(textReader.ReadLine());
                       gi.MaxHeight = float.Parse(textReader.ReadLine());
                       gi.NoiseSpread = float.Parse(textReader.ReadLine());
                       gi.GrassDensity = float.Parse(textReader.ReadLine());

                       // читаем цвет gi.HealthyColor
                       string templine3 = textReader.ReadLine();
                       string[] parts3 = templine3.Split(","[0]);
                       float xx = float.Parse(parts3[0]);
                       float yy = float.Parse(parts3[1]);
                       float zz = float.Parse(parts3[2]);
                       gi.HealthyColor = new Color(xx, yy, zz);

                       // читаем цвет DryColor
                       string templine4 = textReader.ReadLine();
                       string[] parts4 = templine4.Split(","[0]);
                       float xx1 = float.Parse(parts4[0]);
                       float yy1 = float.Parse(parts4[1]);
                       float zz1 = float.Parse(parts4[2]);
                       gi.DryColor = new Color(xx1, yy1, zz1);
                       gi.RenderMode = DetailRenderMode.GrassBillboard; // Этот параметр просто запишем т.к. мы его в файл не писали
                       gi.Billboard = Convert.ToBoolean(textReader.ReadLine());
                       gi.Filemask = textReader.ReadLine();
                       gi.FoldOutStat = true;
                       _grass.Add(gi);
                       _grassFoldout = true;

                       break;

                  case "<TerrainOption>":

                        _imagesPath = textReader.ReadLine(); // подгрузим путь до файлов
                        _heightmapMask = textReader.ReadLine(); // подгрузим имя маски
                        _terrainMask = textReader.ReadLine(); // подгрузим имя маски
                        _depthIndex = Convert.ToInt32(textReader.ReadLine()); // подгрузим разрядность террайна
                        _byteorderIndex = Convert.ToInt32(textReader.ReadLine()); // подгрузим еще какуюто хрень

                        // читаем размер террайна
                        string templine = textReader.ReadLine();
                        string[] parts = templine.Split(","[0]);
                        float x = float.Parse(parts[0]);
                        float y = float.Parse(parts[1]);
                        _heightmapsize = new Vector3(x, y);

                        // читаем цвет
                        string templine1 = textReader.ReadLine();
                        string[] parts1 = templine1.Split(","[0]);
                        float x1 = float.Parse(parts1[0]);
                        float y1 = float.Parse(parts1[1]);
                        float z1 = float.Parse(parts1[2]);
                        _terrainsize = new Vector3(x1, y1, z1);

                        _heightmaperror = Convert.ToInt32(textReader.ReadLine());   // Точность карты
                        _basemapdistance = Convert.ToInt32(textReader.ReadLine());  // Дальность отрисовки карты
                        _castShadows = Convert.ToBoolean(textReader.ReadLine());    // Показывать тень
                        _mat = (Material)AssetDatabase.LoadAssetAtPath(textReader.ReadLine(), typeof(Material));
                        _mat = (Material)EditorGUILayout.ObjectField(_mat, typeof(Material), false);
                        _detailObjectDistance = float.Parse(textReader.ReadLine()); // На каком растоянии Detail объекты будут отображаться на расстоянии.
                        _detailObjectDensity = float.Parse(textReader.ReadLine());
                        _treeDistance = float.Parse(textReader.ReadLine());
                        _treeBillboardDistance = float.Parse(textReader.ReadLine());
                        _treeCrossFadeLength = float.Parse(textReader.ReadLine());
                        _treeMaximumFullLodCount = Convert.ToInt32(textReader.ReadLine());

                        _windspeed = float.Parse(textReader.ReadLine());  // скорость ветра
                        _windsize = float.Parse(textReader.ReadLine());   // размер ветра
                        _bendfactor = float.Parse(textReader.ReadLine()); // тоже ветра

                        // читаем цвет
                        string templine2 = textReader.ReadLine();
                        string[] parts2 = templine2.Split(","[0]);
                        float x2 = float.Parse(parts2[0]);
                        float y2 = float.Parse(parts2[1]);
                        float z2 = float.Parse(parts2[2]);
                        _grasstint = new Color(x2, y2, z2);
                        break;
                }

            }
            textReader.Close();
            //EditorGUILayout.EndHorizontal();
        }
    }
Esempio n. 2
0
 private void AddNewTreemap()
 {
     TreeMapInfo2 tm = new TreeMapInfo2();
     tm.Prefab = null;
     tm.BendFactor = 0;
     tm.ColorVariation = 0;
     tm.HeightScale = 100;
     tm.WidthScale = 100;
     tm.HeightVariation = 0;
     tm.WidthVariation = 0;
     tm.MaxDensity = 1;
     tm.Filemask = "tressmap_x{0}_y{1}";
     tm.FoldOutStat = false;
     _trees.Add(tm);
 }