Skip to content

Commit c7cf18c

Browse files
committed
(fix): Invalidates copy/paste with mixed scene/asset selections
1 parent 4b9b653 commit c7cf18c

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

Editor/CopyPaste.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private static void DoPaste() {
8484

8585
[MenuItem("Assets/IO/Paste %v", true)]
8686
private static bool DoPasteValidate() {
87-
return DefaultValidation() && (_copyBuffer != null && _copyBuffer.Count > 0) || (_cutBuffer != null && _cutBuffer.Count > 0);
87+
return DefaultValidation(false) && (_copyBuffer != null && _copyBuffer.Count > 0) || (_cutBuffer != null && _cutBuffer.Count > 0);
8888
}
8989

9090
[MenuItem("Assets/IO/Cut %x", false, PRIORITY)]
@@ -124,14 +124,18 @@ private static bool DoCutCancelValidate() {
124124
return DefaultValidation() && _cutBuffer != null && _cutBuffer.Count > 0;
125125
}
126126

127-
private static bool DefaultValidation() {
128-
return ValidateNotRestrictedPath() && CollectAssetItems(ref _tmpBuffer);
127+
private static bool DefaultValidation(bool restrictAssets = true) {
128+
return ValidateNotRestrictedPath(restrictAssets) && CollectAssetItems(ref _tmpBuffer);
129129
}
130130

131-
private static bool ValidateNotRestrictedPath() {
131+
private static bool ValidateNotRestrictedPath(bool restrictAssets = true) {
132132
string path = AssetDatabase.GetAssetPath(Selection.activeObject);
133133

134-
return !string.IsNullOrEmpty(path) && !path.Equals("Assets") && !path.StartsWith("Packages");
134+
if (restrictAssets && path.Equals("Assets")) {
135+
return false;
136+
}
137+
138+
return !string.IsNullOrEmpty(path) && !path.StartsWith("Packages");
135139
}
136140

137141
private static void OnProjectGUI(string guid, Rect selectionRect) {
@@ -163,9 +167,18 @@ private static bool CollectAssetItems(ref Dictionary<string, List<AssetItem>> ou
163167
bool hasFolderSelected = false;
164168

165169
foreach (Object o in objects) {
170+
if (!AssetDatabase.IsMainAsset(o)) {
171+
continue;
172+
}
173+
166174
string path = AssetDatabase.GetAssetPath(o).Replace('/', '\\');
167175
string[] parentSplit = path.Split('\\');
168176
string parent = Path.GetDirectoryName(path);
177+
178+
if (string.IsNullOrEmpty(parent)) {
179+
continue;
180+
}
181+
169182
AssetItem item = new AssetItem(path);
170183

171184
if (item.IsFolder) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.nomnom.project-window-extensions",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"displayName": "Project Window Extensions",
55
"description": "This aims to improve the usability of the project window.",
66
"unity": "2020.3",

0 commit comments

Comments
 (0)