Another physical activity, the resources to move. Specific tasks I will not reveal, anyway, is the bottom of the management of the capital and other things.
In order to simplify the operation, I still insist on writing a plug-in, and then feel good to make a small window of their own, wrote a small editor plugin.
OK, this small window completes the function is very simple, is moves the resource to a certain folder. Well, the code is shared as follows,
If you look at the effect, just put it in the project file and restart unity. The code is simple and the comment is not written:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingUnityeditor;usingUnityengine;usingSystem.IO; Public classonekeymove:editorwindow{ PublicRespath Respath; voidStart () {if(respath==NULL) {Respath=NewRespath (); }} [MenuItem ("myutil/One-click Move")] Public Static voidInit () {if(Resources.findobjectsoftypeall<onekeymove> (). Length = =0) { varWin = scriptableobject.createinstance<onekeymove>(); Win.title="One-click Move"; Win. Show (); } } Public voidOngui () {if(Respath = =NULL) {Respath=NewRespath (); } Editorguilayout.labelfield ("Moving Files", Editorstyles.boldlabel); Editorguilayout.space (); Guilayout.beginhorizontal (); Editorguilayout.labelfield ("Current File", Guilayout.width ( the)); Rect Firstrect= Editorguilayout.getcontrolrect (Guilayout.width ( $)); Respath._firstfile=Editorgui.textfield (Firstrect, respath._firstfile); if(Event.current.type = = Eventtype.dragupdated | | Event.current.type = = eventtype.dragexited) &&firstrect.contains (Event.current.mousePosition)) { if(Draganddrop.paths! =NULL&& DragAndDrop.paths.Length >0) { stringSfxpath = draganddrop.paths[0]; if(!string. IsNullOrEmpty (sfxpath) && Event.current.type = =eventtype.dragupdated) {Draganddrop.acceptdrag (); Respath._firstfile=Sfxpath; }}} guilayout.endhorizontal (); Editorguilayout.space (); Guilayout.beginhorizontal (); Editorguilayout.labelfield ("Target", Guilayout.width ( the)); Rect Secondrect= Editorguilayout.getcontrolrect (Guilayout.width ( $)); Respath._secondfile=Editorgui.textfield (secondrect, respath._secondfile); if(Event.current.type = = Eventtype.dragupdated | | Event.current.type = = eventtype.dragexited) &&secondrect.contains (Event.current.mousePosition)) { if(Draganddrop.paths! =NULL&& DragAndDrop.paths.Length >0) { stringSfxpath = draganddrop.paths[0]; if(!string. IsNullOrEmpty (sfxpath) && Event.current.type = =eventtype.dragupdated) {Draganddrop.acceptdrag (); Respath._secondfile=Sfxpath; }}} guilayout.endhorizontal (); Editorguilayout.space (); if(Guilayout.button ("One-click Move")) { stringResname = Respath._firstfile.remove (0, Respath._firstfile.lastindexof ('/') +1); Debug.Log (Resname); stringTargetPath = Respath._secondfile +"/layout/"+Resname; stringRealpath = Application.dataPath.Substring (0, Application.dataPath.LastIndexOf ('/'))+"/"+respath._secondfile +"/layout"; if(!directory.exists (Realpath)) {directory.createdirectory (Realpath); } Assetdatabase.refresh (); Debug.Log (TargetPath); Assetdatabase.moveasset (Respath._firstfile, TargetPath); } editorguilayout.space (); }}[serializable] Public classRespath { Public string_firstfile=""; Public string_secondfile="";}
The Unity editor learns to create its own window