Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using UnityEditor;
- using UnityEngine;
- public static class CopyPath
- {
- const string resources_folder = "Resources/";
- [MenuItem("Assets/Copy Resources Path")]
- static void CopyResourcesPath()
- {
- var selected = Selection.activeObject;
- var path = AssetDatabase.GetAssetPath(selected);
- var textEditor = new TextEditor();
- if (path.Contains(resources_folder))
- {
- var lastIndexOf = path.LastIndexOf(resources_folder, StringComparison.Ordinal) + resources_folder.Length;
- var respath = path.Substring(lastIndexOf, path.Length - lastIndexOf);
- Debug.Log("<color=green>" + respath + " - copied to clipboard.</color>");
- textEditor.text = respath;
- }
- else
- {
- Debug.Log("<color=red>" + path + " is not in resources folder, copied anyway!</color>");
- textEditor.text = path;
- }
- textEditor.Copy();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement