In development, if you just want to quickly view a file (such as a. Lua), you can utilize the right-click function, which is slightly more efficient when you open multiple projects and debug.
wrote a tool class and added two methods: You can use notepad++ or Notepad to quickly open the file.
The code is as follows:
using unityengine;using system.collections;using unityeditor;using thisobject = unityengine.object;using system.threading;using system;public class easytool{ const int openmax = 10; //Maximum number of open files at once const string notepadjj_app_name = "Notepad++.exe"; const string notepad_app_name = "notepad.exe"; /// <summary> /// Open file with notepad++ /// </summary> [ MenuItem ("assets/easytool/open_notepad++")] static public void OPENFORNOTEPADJJ () { int count = 0; foreach (var go in Getselectobject ()) { if (go != null) { string dir_path = GetPath (GO); Invokecmd (Notepadjj_app_name, dir_path); } count++; if (Count > openmax) { break; } } } // <summary> /// open file with Notepad /// </summary> [menuitem ("Assets/easytool/open_notepad")] static public void Openfornotepad () { int count = 0; foreach (Var go in getselectobject ()) { if (go != null) { String dir_path = getpath (GO); &nbsP; invokecmd (Notepad_app_name, dir_path); count++; if (Count > openmax) { break; } } } } /// <summary> /// Call cmd Command /// </summary> public static void invokecmd ( string cmd, string d ir_path) { unityengine.debug.log (CMD); assetdatabase.refresh (); new thread (New threadstart () => { try { System.Diagnostics.Process p = new System.Diagnostics.Process (); p.StartInfo.FileName = cmd; p.StartInfo.Arguments = dir_path; p.start (); p.waitforexit (); p.close (); } catch (Exception e) { debug.log (e.message); } })). Start (); } /// <summary> /// Get selected Files /// </summary> /// <returns> </returns> Static public thisobject[] getselectobject () { if (selection.objects.length == 0) { return new thisobject[0]; } return Selection.objects; } /// <summary> /// Get file path /// </summary> /// <param name= "Go" ></param> /// <returns></ Returns> static public string getpath (ThisObject go) { string str = Application.dataPath.Replace ("Assets", ""); string path = assetdatabase.getassetpath (GO); string dir_path = system.io.path.getfullpath ( Str + path); return dir_path; }}
This article is from the "Wo Love Money" blog, please be sure to keep this source http://mozhenrui.blog.51cto.com/11845221/1976771
Unity3d Right-click to open the file quickly