本文整理汇总了C#中System.Type.GetMethod方法的典型用法代码示例。如果您正苦于以下问题:C# System.Type.GetMethod方法的具体用法?C# System.Type.GetMethod怎么用?C# System.Type.GetMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Type
的用法示例。
在下文中一共展示了System.Type.GetMethod方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FGConsole
static FGConsole()
{
consoleWindowType = typeof(EditorWindow).Assembly.GetType("UnityEditor.ConsoleWindow");
if (consoleWindowType != null)
{
consoleWindowField = consoleWindowType.GetField("ms_ConsoleWindow", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
consoleListViewField = consoleWindowType.GetField("m_ListView", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
consoleLVHeightField = consoleWindowType.GetField("ms_LVHeight", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
consoleActiveTextField = consoleWindowType.GetField("m_ActiveText", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
consoleOnGUIMethod = consoleWindowType.GetMethod("OnGUI", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
}
listViewStateType = typeof(EditorWindow).Assembly.GetType("UnityEditor.ListViewState");
if (listViewStateType != null)
{
listViewStateRowField = listViewStateType.GetField("row", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
}
editorWindowPosField = typeof(EditorWindow).GetField("m_Pos", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
logEntriesType = typeof(EditorWindow).Assembly.GetType("UnityEditorInternal.LogEntries");
if (logEntriesType != null)
{
getEntryMethod = logEntriesType.GetMethod("GetEntryInternal", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
startGettingEntriesMethod = logEntriesType.GetMethod("StartGettingEntries", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
endGettingEntriesMethod = logEntriesType.GetMethod("EndGettingEntries", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
}
logEntryType = typeof(EditorWindow).Assembly.GetType("UnityEditorInternal.LogEntry");
if (logEntryType != null)
{
logEntry = System.Activator.CreateInstance(logEntryType);
logEntryFileField = logEntryType.GetField("file", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
logEntryLineField = logEntryType.GetField("line", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
logEntryInstanceIDField = logEntryType.GetField("instanceID", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
}
}
示例2: OnInspectorGUI
public override void OnInspectorGUI()
{
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
EditorGUIUtility.LookLikeControls();
#else
EditorGUIUtility.labelWidth = 0f;
EditorGUIUtility.fieldWidth = 0f;
#endif
EditorGUI.indentLevel = 0;
var rc = GUILayoutUtility.GetRect(1f, 13f);
rc.yMin -= 5f;
var enabled = GUI.enabled;
GUI.enabled = true;
showInfo = InspectorFoldout(rc, showInfo, targets);
GUI.enabled = enabled;
if (showInfo)
{
if (unityShaderInspectorType == null)
{
unityShaderInspectorType = typeof(Editor).Assembly.GetType("UnityEditor.ShaderInspector");
if (unityShaderInspectorType != null)
{
const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
internalSetTargetsMethod = unityShaderInspectorType.GetMethod("InternalSetTargets", flags);
}
}
if (targets != null && internalSetTargetsMethod != null)
{
if (unityShaderInspector == null)
{
unityShaderInspector = Editor.CreateEditor(target, unityShaderInspectorType);
// unityShaderInspector = (Editor) CreateInstance(unityShaderInspectorType);
if (unityShaderInspector)
internalSetTargetsMethod.Invoke(unityShaderInspector, new object[] { targets.Clone() });
}
if (unityShaderInspector)
unityShaderInspector.OnInspectorGUI();
}
}
var assetPath = AssetDatabase.GetAssetPath(target);
if (!string.IsNullOrEmpty(assetPath) && assetPath.StartsWith("Assets/"))
base.OnInspectorGUI();
}
示例3: GradientWrapper
/// <summary>
/// Perform one-off setup when class is accessed for first time.
/// </summary>
static GradientWrapper()
{
#if (UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9)
Assembly editorAssembly = typeof(Editor).Assembly;
s_tyGradientColorKey = editorAssembly.GetType("UnityEditor.GradientColorKey");
s_tyGradientAlphaKey = editorAssembly.GetType("UnityEditor.GradientAlphaKey");
// Note that `Gradient` is defined in the editor namespace in Unity 3.5.7!
s_tyGradient = editorAssembly.GetType("UnityEditor.Gradient");
s_miEvaluate = s_tyGradient.GetMethod("CalcColor", BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(float) }, null);
s_piColorKeys = s_tyGradient.GetProperty("colorKeys", BindingFlags.Public | BindingFlags.Instance);
s_piAlphaKeys = s_tyGradient.GetProperty("alphaKeys", BindingFlags.Public | BindingFlags.Instance);
#else
// In Unity 4 this is easy :)
s_tyGradient = typeof(Gradient);
#endif
}
示例4: FindMember
private static System.Func<object, object> FindMember(Type type, string name)
{
if (type == null)
throw new ArgumentNullException("type");
if (name == null)
throw new ArgumentNullException("name");
lock (_memberAccessors)
{
Dictionary<string, System.Func<object, object>> members;
System.Func<object, object> accessor = null;
if (_memberAccessors.TryGetValue(type, out members))
{
if (members.TryGetValue(name, out accessor))
return accessor;
}
else
{
members = new Dictionary<string, System.Func<object, object>>();
_memberAccessors[type] = members;
}
// must look up using reflection
string methodSuffix = char.ToUpperInvariant(name[0]) + name.Substring(1);
bool checkOriginalName = !string.Equals(methodSuffix, name);
MethodInfo method = null;
if (method == null)
{
PropertyInfo p = type.GetProperty(methodSuffix);
if (p == null && checkOriginalName)
p = type.GetProperty(name);
if (p != null)
method = p.GetGetMethod();
}
if (method == null)
{
method = type.GetMethod("Get" + methodSuffix, Type.EmptyTypes);
if (method == null && checkOriginalName)
method = type.GetMethod("Get" + name, Type.EmptyTypes);
}
if (method == null)
{
method = type.GetMethod("get_" + methodSuffix, Type.EmptyTypes);
if (method == null && checkOriginalName)
method = type.GetMethod("get_" + name, Type.EmptyTypes);
}
if (method != null)
{
accessor = BuildAccessor(method);
}
else
{
// try for an indexer
method = type.GetMethod("get_Item", new Type[] { typeof(string) });
if (method == null)
{
var property = type.GetProperties().FirstOrDefault(IsIndexer);
if (property != null)
method = property.GetGetMethod();
}
if (method != null)
{
accessor = BuildAccessor(method, name);
}
else
{
// try for a visible field
FieldInfo field = type.GetField(name);
// also check .NET naming convention for fields
if (field == null)
field = type.GetField("_" + name);
if (field != null)
accessor = BuildAccessor(field);
}
}
members[name] = accessor;
return accessor;
}
}
示例5: API
static API()
{
const BindingFlags instanceMember = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
const BindingFlags staticMember = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
var editorAssembly = typeof(EditorWindow).Assembly;
containerWindowType = editorAssembly.GetType("UnityEditor.ContainerWindow");
viewType = editorAssembly.GetType("UnityEditor.View");
dockAreaType = editorAssembly.GetType("UnityEditor.DockArea");
splitViewType = editorAssembly.GetType("UnityEditor.SplitView");
mainWindowType = editorAssembly.GetType("UnityEditor.MainWindow");
windowLayoutType = editorAssembly.GetType("UnityEditor.WindowLayout");
parentField = typeof(EditorWindow).GetField("m_Parent", instanceMember);
if (viewType != null)
parentProperty = viewType.GetProperty("parent", instanceMember);
if (dockAreaType != null)
{
panesField = dockAreaType.GetField("m_Panes", instanceMember);
addTabMethod = dockAreaType.GetMethod("AddTab", new System.Type[] { typeof(EditorWindow) });
}
if (containerWindowType != null)
{
windowsField = containerWindowType.GetProperty("windows", staticMember);
mainViewField = containerWindowType.GetProperty("mainView", instanceMember);
}
if (viewType != null)
allChildrenField = viewType.GetProperty("allChildren", instanceMember);
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0
cachedTitleContentField = typeof(EditorWindow).GetProperty("cachedTitleContent", instanceMember);
#endif
// FieldInfo windowsReorderedField = typeof(EditorApplication).GetField("windowsReordered", staticMember);
//Debug.Log("windowsReorderedField " + windowsReorderedField);
// if (windowsReorderedField != null)
// windowsReordered = windowsReorderedField.GetValue(null) as EditorApplication.CallbackFunction;
//Debug.Log("windowsReordered " + windowsReordered);
System.Type projectWindowUtilType = editorAssembly.GetType("UnityEditor.ProjectWindowUtil");
if (projectWindowUtilType != null)
createAssetMethod = projectWindowUtilType.GetMethod("CreateAsset", new System.Type[] { typeof(Object), typeof(string) });
if (windowLayoutType != null)
{
isMaximizedMethod = windowLayoutType.GetMethod("IsMaximized", staticMember);
maximizeMethod = windowLayoutType.GetMethod("Maximize", staticMember);
unMaximizeMethod = windowLayoutType.GetMethod("Unmaximize", staticMember);
if (isMaximizedMethod == null || maximizeMethod == null || unMaximizeMethod == null)
windowLayoutType = null;
}
}
示例6: ProjectBrowserHelper
static ProjectBrowserHelper()
{
Assembly editorAssembly = Assembly.GetAssembly( typeof( EditorWindow ) );
foreach( string typeName in projecBrowserTypeNames )
{
projectBrowserType = editorAssembly.GetType( typeName );
if( projectBrowserType != null )
{
setSearchMethod = projectBrowserType.GetMethod( "SetSearch", new System.Type[] { typeof( string ) } );
if( setSearchMethod != null )
{
break;
}
}
}
}
示例7: OpenSIPreferences
public static void OpenSIPreferences()
{
if (preferencesWindowType == null)
{
preferencesWindowType = typeof(Editor).Assembly.GetType("UnityEditor.PreferencesWindow");
sectionType = typeof(Editor).Assembly.GetType("UnityEditor.PreferencesWindow+Section");
if (preferencesWindowType != null && sectionType != null)
{
field_Sections = preferencesWindowType.GetField("m_Sections", BindingFlags.Instance | BindingFlags.NonPublic);
field_SelectedSectionIndex = preferencesWindowType.GetField("m_SelectedSectionIndex", BindingFlags.Instance | BindingFlags.NonPublic);
field_Content = sectionType.GetField("content");
if (field_Sections != null && field_SelectedSectionIndex != null && field_Content != null)
{
method_ShowPreferencesWindow = preferencesWindowType.GetMethod("ShowPreferencesWindow", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
}
}
if (method_ShowPreferencesWindow != null)
{
method_ShowPreferencesWindow.Invoke(null, null);
EditorApplication.update -= SwitchToScriptInspectorPage;
EditorApplication.update += SwitchToScriptInspectorPage;
}
}