I feel like a lot of the unnecessary clicks I have to make are because clicking on folder assets in my project change my inspector.
For example, I click on an asset (say, a ScriptableObject).
I look at its Inspector, and say “Hey, I need to drag something into there”.
I then remember: “Ah darn! It’s in that folder 3 levels deep somewhere…”
I go clicking through folders.
“Ah darn! My inspector changed!”
I then have to click on the original asset.
“Ah darn, I went to the wrong folder for the 2nd asset!”
I then click on some more folders.
“Ah darn! My inspector changed!”
…
I don’t see why clicking on folders has to change our inspector, when there is absolutely nothing for us to do with them in the Inspector.
Maybe my proposed solution would break other things, but it’s a UX problem worth looking into, even if you don’t necessarily make folders not change your inspector.
Or perhaps, make it an option in Preferences to not switch inspectors upon selecting a folder asset?
Disclaimers:
I gotta say though, the Alt + P shortcut has really helped in recent versions.
I could lock my inspector, but that’ll result in 4 more clicks. (2 to lock it, and 2 more to unlock it, if I remember that later…)
I also don’t lock my inspector, cause weird things happen (glitching and stuff, especially if it’s locked for too long, between hot/domain reloads, etc…)
Agreed, I found this thread while looking to see if there was a way to disable the folders from showing up in the inspector. It seems so unnecessary and just forces me to have to keep re-selecting objects. I would love to at least see an option to disable this!
Oooh @ok8596_1 Maybe in the meantime we could write an editor extension that detects selection changes to folder assets, and selects whatever it was previously anytime a folder is selected.
I have been quite busy lately but if I find time, I’ll definitely share.
While the selection workflow really needs an overhaul, I don’t believe disabling folder inspectors will do much good. On the contrary, I think it’s a feature that could be used more productively by adding custom features or info to the folder inspector. For example, if you’ve setup a custom import pipeline you can use the folder inspector to edit per-folder import rules. I’ve used folders this way in the past and wouldnt want Unity to break this.
Overall, I think there are other UX improvements which would make this request obsolete: a builtin history panel, back/forward navigation for selection including hotkey support, the new properties panel that can be popped out of almost anything or the planned workspaces/global tabs feature.
I was going to go all devil’s advocate and point out that the folder inspector is useful to allow you to rename the folder, especially that one time Unity had a bug where you couldn’t rename anything but via the Inspector. But it looks like you can’t rename the folder in the inspector anymore (I’m pretty sure that feature existed back in the day). So sadly I have to side with the OP
There is the lock solution listed above, but it has drawbacks, as noted above.
There is one more even crazier lock solution that might help during times when you have a LOT of stuff to drag around:
right click on the inspector window tab and open… another inspector window! (Yes, you can have more than one)
lock ONE of the inspector windows, then go nuts with the other to find what you want to drag.
This is coincidentally how you drag a particular Component into a slot, such as when there is more than a single collider and you want a very specific one.
It’s also how to drag a whole pile of things in at once, such as a list of sprites.
I’ve made a little editor script to do this functionality.
If you select a folder after selecting any other asset, it will reselect the asset and lock the inspector, and unlock as soon as any other asset is selected. If your inspector is already locked it will do nothing. Hope this is useful!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
//Code by Albarnie
[InitializeOnLoad]
public class FolderSelectionHelper
{
//The last object we had selected
public static Object lastActiveObject;
//Object to select the next frame
public static Object objectToSelect;
//Whether we have locked the inspector
public static bool hasLocked;
static FolderSelectionHelper()
{
Selection.selectionChanged += OnSelectionChanged;
EditorApplication.update += OnUpdate;
//Restore folder lock status
hasLocked = EditorPrefs.GetBool("FolderSelectionLocked", false);
}
static void OnSelectionChanged()
{
if (lastActiveObject != null && Selection.activeObject != null)
{
//If the selection has actually changed
if (Selection.activeObject != lastActiveObject)
{
//If the new object is a folder, reselect our old object
if (IsAssetAFolder(Selection.activeObject))
{
//We have to select the object the next frame, otherwise it will not register
objectToSelect = lastActiveObject;
}
else
{
UnLockFolders();
//Update the last object
lastActiveObject = Selection.activeObject;
}
}
}
else if (!IsAssetAFolder(Selection.activeObject))
{
lastActiveObject = Selection.activeObject;
UnLockFolders();
}
}
//We have to do selecting in the next editor update because Unity does not allow selecting another object in the same editor update
static void OnUpdate()
{
//If the editor is locked then we don't care
if (objectToSelect != null && !ActiveEditorTracker.sharedTracker.isLocked)
{
//Select the new object
Selection.activeObject = objectToSelect;
LockFolders();
lastActiveObject = objectToSelect;
objectToSelect = null;
}
else
{
objectToSelect = null;
}
}
static void LockFolders()
{
ActiveEditorTracker.sharedTracker.isLocked = true;
hasLocked = true;
//We store the state so that if we compile or leave the editor while the folders are locked then the state is kept
EditorPrefs.SetBool("FolderSelectionLocked", true);
}
static void UnLockFolders()
{
//Only unlock inspector if we are the one who locked it
if (hasLocked)
{
ActiveEditorTracker.sharedTracker.isLocked = false;
hasLocked = false;
EditorPrefs.SetBool("FolderSelectionLocked", false);
}
}
private static bool IsAssetAFolder(Object obj)
{
string path = "";
if (obj == null)
{
return false;
}
//Get the path to the asset
path = AssetDatabase.GetAssetPath(obj.GetInstanceID());
//If the asset is a directory (i.e a folder)
if (path.Length > 0 && Directory.Exists(path))
{
return true;
}
return false;
}
}
EDIT:
added prefs so that it doesnt lock your inspector when you leave the editor
Yeah it is unnecessary and always makes me force to use left side of project window to navigate around folders. It is a bit frustrating but that way it won’t affect inspector.