強火で進め

このブログではプログラム関連の記事を中心に書いてます。

Project View で選択中のオブジェクトを取得するスクリプト

using UnityEngine;
using UnityEditor;

public class Test : MonoBehaviour {
	[MenuItem("Assets/Show Selection Objects")]
	static void ShowSelectionObjects()
	{
		Object[] selectedAsset = Selection.GetFiltered (typeof(Object), SelectionMode.Assets);
		foreach (var go in selectedAsset) {
			Debug.Log (go.name + " : " + go.GetType ());
		}
	}
}

必要に応じて SelectionMode.Assets の部分は変更して下さい。

Unity - スクリプトリファレンス: SelectionMode
https://docs.unity3d.com/jp/540/ScriptReference/SelectionMode.html