- Home /
Question by
hmb3141 · Aug 12, 2015 at 08:55 AM ·
editorselectionassetdatabase
Settting Selection.activeObject to multiple items
I'm writing a little editor script to save and recall (reselect/highlight them) a selection of items from the project browser.
I've got the saving part working. But when recalling I can't figure out how to select more than one item in the project browser tab. Here's my code, showing the selection of just ONE object.
[MenuItem("Igloo/Build Packages/Select Windows Items")]
public static void SelectWindowsPackageItems() {
string savePath = Application.dataPath + "/IglooTools/Settings/WindowsPackagePaths.csv";
string[] paths = ReadCSV(savePath);
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(paths[0]);
foreach (string path in paths) {
}
}
Comment
Best Answer
Answer by Baste · Aug 12, 2015 at 09:04 AM
Selection.objects or Selection.transforms are the ways to get/set several selected objects. Since you're working with assets, you want to use objects.
That's perfect, thanks. Here's my full method.
public static void SelectWindowsBuildItems() {
string savePath = Application.dataPath + "/IglooTools/Settings/WindowsPackagePaths.csv";
string[] paths = ReadCSV(savePath);
Object[] objects = new Object[paths.Length];
for (int i=0 ; i<paths.Length ; i++) {
objects[i] = AssetDatabase.Load$$anonymous$$ainAssetAtPath(paths[i]);
}
Selection.objects = objects;
}