예제 #1
0
    void OnGUI()
    {
        GUILayout.BeginVertical();
        GUILayout.Space(10);

        GUI.skin.label.fontSize  = 14;
        GUI.skin.label.fontStyle = FontStyle.Bold;
        GUILayout.Label("输入相应参数");
        GUI.skin.label.fontStyle = FontStyle.Normal;
        GUI.skin.label.fontSize  = 12;
        GUILayout.Space(10);
        mapName = EditorGUILayout.TextField("设置地图名字", mapName);
        GUILayout.Space(10);
        mapWidth = EditorGUILayout.TextField("设置地图宽度", mapWidth);
        GUILayout.Space(10);
        EditorGUI.BeginDisabledGroup(true);  //如果nextPath == null 为真,在Inspector面板上显示,承灰色(即不可操作)
        mapLength = EditorGUILayout.TextField("设置地图长度", mapWidth);
        EditorGUI.EndDisabledGroup();
        GUILayout.Space(10);

        IsDefault = EditorGUILayout.Toggle("是否使用默认定点密度", IsDefault);
        if (!IsDefault)
        {
            GUILayout.Space(10);
            mapPd = EditorGUILayout.TextField("设置地图定点密度(建议为宽度X5)", mapPd);
        }
        else
        {
            mapPd = "" + int.Parse(mapWidth) * 5;
        }

        GUILayout.Space(10);
        if (GUILayout.Button("选择保存文件夹"))
        {
            savePath = EditorUtility.OpenFolderPanel("选择保存的文件夹", "Assets/", "");
        }
        GUILayout.Space(10);
        GUILayout.EndVertical();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("确定"))
        {
            if (mapWidth.Length > 0)
            {
                XLZTerrainEditor.OpenImage(int.Parse(mapWidth), uint.Parse(mapPd), savePath, mapName);
                instance.Close();
                EditorUtility.DisplayDialog("创建结果", "创建成功", "确定");
            }
            else
            {
                Debug.LogError("请输入相应的值");
            }
        }
        GUILayout.Space(120);
        if (GUILayout.Button("取消"))
        {
            instance.Close();
        }
        GUILayout.EndHorizontal();
    }
예제 #2
0
    void OnGUI()
    {
        EditorGUILayout.Space();
        GUILayout.BeginVertical();
        GUILayout.Space(10);

        GUI.skin.label.fontSize  = 14;
        GUI.skin.label.fontStyle = FontStyle.Bold;
        GUILayout.Label("输入相应参数");
        GUI.skin.label.fontStyle = FontStyle.Normal;
        GUI.skin.label.fontSize  = 12;
        GUILayout.Space(10);
        mapName = EditorGUILayout.TextField("设置地图名字", mapName);
        GUILayout.Space(10);
        mapWidth = EditorGUILayout.IntField("设置小地图行数", mapWidth);
        GUILayout.Space(10);

        mapLength = EditorGUILayout.IntField("设置小地图列数", mapLength);

        GUILayout.Space(10);
        mapHight = EditorGUILayout.IntField("设置地图高度", mapHight);
        GUILayout.Space(10);
        highttextureAcc = EditorGUILayout.Slider("设置高度贴图精度", highttextureAcc, 1, 200);
        GUILayout.Space(10);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("选择保存目录"))
        {
            sevepath = EditorUtility.OpenFolderPanel("选择文件", "Assets/", "");
        }
        GUILayout.Space(10);
        EditorGUI.BeginDisabledGroup(true);
        EditorGUILayout.TextField("", sevepath);
        EditorGUI.EndDisabledGroup();
        GUILayout.EndHorizontal();

        GUILayout.Space(10);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("选择.RAW文件夹"))
        {
            rawpath = EditorUtility.OpenFolderPanel("选择文件", "C:\\Users\\Administrator\\Desktop", "");
        }
        GUILayout.Space(10);
        EditorGUI.BeginDisabledGroup(true);
        EditorGUILayout.TextField("", rawpath);
        EditorGUI.EndDisabledGroup();
        GUILayout.EndHorizontal();

        GUILayout.Space(10);

        GUILayout.Space(10);
        maptextureCount = EditorGUILayout.IntField("地表贴图数量", maptextureCount);
        int count = maptextureCount < 1? 1: maptextureCount;

        if (count != texture2s.Length)
        {
            Texture2D[] oldlist = texture2s;
            texture2s = new Texture2D[count];
            for (int i = 0; i < texture2s.Length; i++)
            {
                if (i <= oldlist.Length - 1)
                {
                    texture2s[i] = oldlist[i];
                }
            }
        }

        GUILayout.Space(10);
        GUILayout.BeginVertical();
        for (int i = 0; i < texture2s.Length; i++)
        {
            if (i == 0)
            {
                GUILayout.BeginHorizontal();
            }
            texture2s[i] = EditorGUILayout.ObjectField(texture2s[i], typeof(Texture2D), false, GUILayout.Width(100), GUILayout.Height(100)) as Texture2D;
            GUILayout.Space(10);
            if (i != 0 && (i + 1) % 4 == 0)
            {
                GUILayout.EndHorizontal();
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();

        GUILayout.Space(10);
        GUILayout.EndVertical();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("确定"))
        {
            XLZTerrainEditor.CreateTerrain(mapName, mapWidth, mapLength, mapHight, highttextureAcc, sevepath, rawpath, texture2s);
        }
        GUILayout.Space(120);
        if (GUILayout.Button("取消"))
        {
            instance.Close();
        }
        GUILayout.EndHorizontal();
    }