本文整理汇总了C#中UnityEngine.GUIContent.Prepend方法的典型用法代码示例。如果您正苦于以下问题:C# GUIContent.Prepend方法的具体用法?C# GUIContent.Prepend怎么用?C# GUIContent.Prepend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.GUIContent
的用法示例。
在下文中一共展示了GUIContent.Prepend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypeDropDown
public static System.Type TypeDropDown(Rect position, GUIContent label, System.Type baseType, System.Type selectedType, bool allowAbstractTypes = false, bool allowInterfaces = false, System.Type defaultType = null, TypeDropDownListingStyle listType = TypeDropDownListingStyle.Namespace)
{
if (!TypeUtil.IsType(selectedType, baseType)) selectedType = null;
//var knownTypes = (from ass in System.AppDomain.CurrentDomain.GetAssemblies()
// from tp in ass.GetTypes()
// where TypeUtil.IsType(tp, baseType) && (allowAbstractTypes || !tp.IsAbstract) && (allowInterfaces || !tp.IsInterface)
// orderby tp.FullName.Substring(tp.FullName.LastIndexOf(".") + 1) ascending
// select tp).ToArray();
var knownTypes = (from tp in TypeUtil.GetTypesAssignableFrom(baseType)
where (allowAbstractTypes || !tp.IsAbstract) && (allowInterfaces || !tp.IsInterface)
orderby tp.FullName.Substring(tp.FullName.LastIndexOf(".") + 1) ascending
select tp).ToArray();
GUIContent[] knownTypeNames = null;
switch (listType)
{
case TypeDropDownListingStyle.Namespace:
knownTypeNames = knownTypes.Select((tp) =>
{
return new GUIContent(tp.FullName.Replace(".", "/"));
}).ToArray();
break;
case TypeDropDownListingStyle.Flat:
knownTypeNames = (from tp in knownTypes select new GUIContent(tp.Name)).ToArray();
break;
case TypeDropDownListingStyle.ComponentMenu:
knownTypeNames = knownTypes.Select((tp) =>
{
var menuAttrib = tp.GetCustomAttributes(typeof(AddComponentMenu), false).FirstOrDefault() as AddComponentMenu;
if (menuAttrib != null && !string.IsNullOrEmpty(menuAttrib.componentMenu))
{
return new GUIContent(menuAttrib.componentMenu);
}
else if (tp.FullName == tp.Name)
{
return new GUIContent("Scripts/" + tp.Name);
}
else
{
if (tp.FullName.StartsWith("UnityEngine."))
{
return new GUIContent(tp.FullName.Replace(".", "/"));
}
else
{
return new GUIContent("Scripts/" + tp.FullName.Replace(".", "/"));
}
}
}).ToArray();
break;
default:
knownTypeNames = new GUIContent[0];
break;
}
if (defaultType == null)
{
knownTypes = knownTypes.Prepend(null).ToArray();
knownTypeNames = knownTypeNames.Prepend(new GUIContent("Nothing")).ToArray();
}
int index = knownTypes.IndexOf(selectedType);
index = EditorGUI.Popup(position, label, index, knownTypeNames);
return (index >= 0) ? knownTypes[index] : defaultType;
}