Beispiel #1
0
    void OnGUI()
    {
        int luaIDETypeIndex = EditorPrefs.GetInt("LUA_IDE_TYPE");

        luaIDETypeIndex = EditorGUILayout.Popup(luaIDETypeIndex, luaIDETypes);
        EditorPrefs.SetInt("LUA_IDE_TYPE", luaIDETypeIndex);

        LuaIDEType luaIDEType = (LuaIDEType)luaIDETypeIndex;

        if (luaIDEType == LuaIDEType.IDEA)
        {
            GUILayout.Label("IdeaIDE路径:");
            string ideaPath = EditorPrefs.GetString("IDEA_IDE_Path");
            GUILayout.TextField(ideaPath);
            if (GUILayout.Button("Browse"))
            {
                ideaPath = UnityEditor.EditorUtility.OpenFilePanel("选择路径", "", "exe");
                EditorPrefs.SetString("IDEA_IDE_Path", ideaPath);
            }
        }
        else if (luaIDEType == LuaIDEType.VSCode)
        {
            GUILayout.Label("VSCode IDE路径:");
            string vscodePath = EditorPrefs.GetString("VSCode_IDE_Path");
            GUILayout.TextField(vscodePath);
            if (GUILayout.Button("Browse"))
            {
                vscodePath = UnityEditor.EditorUtility.OpenFilePanel("选择路径", "", "exe");
                EditorPrefs.SetString("VSCode_IDE_Path", vscodePath);
            }
        }
    }
Beispiel #2
0
    static bool OpenLuaLocation(Match match)
    {
        if (!match.Success)
        {
            return(false);
        }
        int        luaIDETypeIndex = EditorPrefs.GetInt("LUA_IDE_TYPE");
        LuaIDEType luaIDEType      = (LuaIDEType)luaIDETypeIndex;

        string idePath = string.Empty;

        if (luaIDEType == LuaIDEType.IDEA)
        {
            idePath = EditorPrefs.GetString("IDEA_IDE_Path");
        }
        else if (luaIDEType == LuaIDEType.VSCode)
        {
            idePath = EditorPrefs.GetString("VSCode_IDE_Path");
        }


        if (string.IsNullOrEmpty(idePath) || !System.IO.File.Exists(idePath))
        {
            return(false);
        }


        while (match.Success)
        {
            string pathLine = match.Groups[1].Value;
            // UnityEngine. Debug.LogError(pathLine);
            if (!pathLine.Contains("LogSubsystem.cs"))//一直为true
            {
                int    spliteIndex = pathLine.LastIndexOf(':');
                string path        = pathLine.Substring(0, spliteIndex);
                int    line        = System.Convert.ToInt32(pathLine.Substring(spliteIndex + 1));
                string s           = path.Replace("\t", "");
                for (int i = 0; i < XLuaManager.m_path.Count; i++)
                {
                    // UnityEngine.Debug.LogError(XLuaManager.m_path[i] + "==s==" + s);
                    if (XLuaManager.m_path[i].Contains(s))//xlua 里所有lua 文件地址合集
                    {
                        path = XLuaManager.m_path[i];
                        break;
                    }
                }
                string args = string.Empty;
                // if (luaIDEType == LuaIDEType.IDEA)
                // {
                //     args = string.Format("{0}:{1}", path.Replace("\\", "/"), line);
                // }
                // else if (luaIDEType == LuaIDEType.VSCode)
                {
                    args = string.Format("-g {0}:{1}", path.Replace("\\", "/"), line);
                }
                // UnityEngine.Debug.LogError(args);
                Process          process   = new Process();
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.FileName               = idePath;
                startInfo.Arguments              = args;
                startInfo.UseShellExecute        = false;
                startInfo.CreateNoWindow         = false;
                startInfo.RedirectStandardOutput = false;
                process.StartInfo = startInfo;
                process.Start();
                return(true);
            }
            match = match.NextMatch();
        }
        return(false);
    }