Last active
May 18, 2018 10:06
-
-
Save nicoplv/ef774d1c82a5bdedb88085775c61e6da to your computer and use it in GitHub Desktop.
Revisions
-
nicoplv revised this gist
May 9, 2018 . No changes.There are no files selected for viewing
-
nicoplv revised this gist
May 9, 2018 . No changes.There are no files selected for viewing
-
nicoplv created this gist
May 8, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ using UnityEngine; using UnityEditor; using System.Text.RegularExpressions; using System.IO; public class ReimportAsset : MonoBehaviour { #region MenuItem Methods [MenuItem("Assets/Reimport from ~ &R", false, priority = 40)] public static void ReimportFromWorkFile() { if (Selection.activeObject == null) return; bool refresh = false; Regex regex = new Regex("Assets/([^/]*)(.*)"); string dataPath = Application.dataPath.Replace("Assets", ""); foreach (UnityEngine.Object iObject in Selection.objects) { string assetPath = dataPath + AssetDatabase.GetAssetPath(iObject); string assetPathWork = regex.Replace(assetPath, "Assets/" + "$1" + "~" + "$2"); if (!File.Exists(assetPathWork)) Debug.Log("File " + iObject.name + "can't be reimport, the work file doesn't exist :("); else { File.Copy(assetPathWork, assetPath, true); refresh = true; } } if(refresh) AssetDatabase.Refresh(); } [MenuItem("Assets/Reimport from ~ &R", true, priority = 40)] public static bool ReimportFromWorkFileValidate() { if (Selection.activeObject == null) return false; return true; } #endregion }