/// <summary> /// 加载编辑器变量 /// </summary> private void Load() { shaderOpenMode = (CodeOpneMode)EditorPrefs.GetInt("shaderMode", 1); csOpenMode = (CodeOpneMode)EditorPrefs.GetInt("csMode", 0); jsonOpenMode = (CodeOpneMode)EditorPrefs.GetInt("jsonMode", 1); cgincOpenMode = (CodeOpneMode)EditorPrefs.GetInt("cgincMode", 1); }
private void OnGUI() { GUI.backgroundColor = new Color32(0, 170, 255, 50); EditorGUILayout.BeginVertical("box"); GUI.backgroundColor = new Color32(255, 255, 0, 180); shaderOpenMode = (CodeOpneMode)EditorGUILayout.EnumPopup("Shader", shaderOpenMode); csOpenMode = (CodeOpneMode)EditorGUILayout.EnumPopup("CS", csOpenMode); EditorGUILayout.EndVertical(); }
/// <summary> /// 通过打开方式获取exe完整路径 /// </summary> private static string GetFileFullname(CodeOpneMode mode) { string editorPath; switch (mode) { case CodeOpneMode.VSCode: editorPath = Environment.GetEnvironmentVariable("VSCode_Path"); return(editorPath == null ? null : editorPath + (editorPath.EndsWith("/") ? "" : "/") + "Code.exe"); case CodeOpneMode.Sublime: editorPath = Environment.GetEnvironmentVariable("Sublime_Path"); return(editorPath == null ? null : editorPath + (editorPath.EndsWith("/") ? "" : "/") + "sublime_text.exe"); default: return(null); } }
/// <summary> /// 打开文件 /// </summary> private static bool OpenAssetWithEnd(CodeOpneMode mode, string strFileName) { string fullName = GetFileFullname(mode); if (fullName == null) { return(false); } Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.FileName = GetFileFullname(mode); startInfo.Arguments = "\"" + strFileName + "\""; process.StartInfo = startInfo; process.Start(); return(true); }