SelectionMode 选择模式

SelectionMode 选择模式

SelectionMode可以用于Selection.GetTransforms返回的选择。

注意:这是一个编辑器类,如果想使用它你需要把它放到工程目录下的Assets/Editor文件夹下。编辑器类在UnityEditor命名空间下。所以当使用C#脚本时,你需要在脚本前面加上 "using UnityEditor"引用。

默认的transform选择模式为:SelectionMode.TopLevel | SelectionMode.ExcludePrefab | SelectionMode.Editable

Values

Unfiltered: 返回整个选择。

TopLevel:仅返回最顶层选择的变换;其他选择的子对象将被过滤出。

Deep:返回选择和所有选择的子变换。

ExcludePrefab:从选择中排除任何预制。

Editable:排除任何对象不得修改。

Assets:仅返回资源目录中的资源对象。

DeepAssets:如果选择包含文件夹,也包含所有资源和子目录。


打包资源:

static void AssetBundle_BuildWebPlayerAndroid()
	{
		BuildAssetBundle(BuildTarget.Android);
	}
static void AssetBundle_BuildWebPlayerIOS()
	{
		BuildAssetBundle(BuildTarget.iPhone);
	}

static void BuildAssetBundle(BuildTarget buildTarget)
	{
		
		Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
		if (selection.Length > 0)
		{
			string fullpath = AssetDatabase.GetAssetPath(selection[0]);
			string filename = Path.GetFileNameWithoutExtension(fullpath);
			string path = EditorUtility.SaveFilePanel("Save Resource", "", filename, "unity3d");
			if (path.Length != 0)
			{
				BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path,
				                               BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets,
				                               buildTarget);
			}
		}
	}



你可能感兴趣的:(unity3d,编辑器,unity)