unity修改编辑器文件路径

文件路径修改:

using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;

public class ModifyFilePath : EditorWindow {
    private static ModifyFilePath window;
    private static string excelOutDir = "";
    private static string jsonOutDir = "";

    [MenuItem("AOT-Faith-Tools/DataOperatorTool/修改文件路径")]
    static void ModfyFilePath()
    {
        window = GetWindow<ModifyFilePath>("修改文件路径");
        window.position = new Rect(700f, 300f, 530f, 400f);
    }

    void OnGUI()
    {
        GUILayout.BeginVertical();
        GUILayout.Space(10.0f);
        GUILayout.BeginHorizontal();

        GUILayout.Label("excel导出路径", new GUILayoutOption[] { GUILayout.Width(90) });
        GUIStyle tryStyle = new GUIStyle(GUI.skin.GetStyle("TextField"));
        tryStyle.alignment = TextAnchor.LowerLeft;
        GUILayout.TextField(excelOutDir, tryStyle, new GUILayoutOption[] { GUILayout.Width(330) });
        GUILayout.Space(10.0f);
        if (GUILayout.Button("sel", new GUILayoutOption[] { GUILayout.Width(40.0f) }))
        {
            excelOutDir = EditorUtility.OpenFolderPanel("选择要导出的目录",Application.dataPath, "");
        }

        if (GUILayout.Button("save", new GUILayoutOption[] { GUILayout.Width(40.0f) }))
        {
            if(!string.IsNullOrEmpty(excelOutDir))
                PlayerPrefs.SetString("excelPath", excelOutDir + "/");
        }

        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("json导出路径", new GUILayoutOption[] { GUILayout.Width(90) });
        GUILayout.TextField(jsonOutDir, tryStyle, new GUILayoutOption[] { GUILayout.Width(330) });
        GUILayout.Space(10.0f);
        if (GUILayout.Button("sel", new GUILayoutOption[] { GUILayout.Width(40.0f) }))
        {
            jsonOutDir = EditorUtility.OpenFolderPanel("选择要导出的目录", Application.dataPath, "");
        }

        if (GUILayout.Button("save", new GUILayoutOption[] { GUILayout.Width(40.0f) }))
        {
            if (!string.IsNullOrEmpty(jsonOutDir))
                PlayerPrefs.SetString("jsonPath", jsonOutDir + "/");
        }

        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
    }
}
 

猜你喜欢

转载自blog.csdn.net/aihong_1314/article/details/85917381