private static void AddFunctionsForScript(GenericMenu menu, SerializedProperty listener, TesityEventDrawer.ValidMethodMap method, string targetName) { TestityPersistentListenerMode mode = method.mode; UnityEngine.Object objectReferenceValue = listener.FindPropertyRelative("m_Target").objectReferenceValue; string stringValue = listener.FindPropertyRelative("m_MethodName").stringValue; TestityPersistentListenerMode mode2 = TesityEventDrawer.GetMode(listener.FindPropertyRelative("m_Mode")); SerializedProperty serializedProperty = listener.FindPropertyRelative("m_Arguments").FindPropertyRelative("m_ObjectArgumentAssemblyTypeName"); StringBuilder stringBuilder = new StringBuilder(); int num = method.methodInfo.GetParameters().Length; for (int i = 0; i < num; i++) { ParameterInfo parameterInfo = method.methodInfo.GetParameters()[i]; stringBuilder.Append(string.Format("{0}", TesityEventDrawer.GetTypeName(parameterInfo.ParameterType))); if (i < num - 1) { stringBuilder.Append(", "); } } bool flag = objectReferenceValue == method.target && stringValue == method.methodInfo.Name && mode == mode2; if (flag && mode == TestityPersistentListenerMode.Object && method.methodInfo.GetParameters().Length == 1) { flag &= (method.methodInfo.GetParameters()[0].ParameterType.AssemblyQualifiedName == serializedProperty.stringValue); } string formattedMethodName = TesityEventDrawer.GetFormattedMethodName(targetName, method.methodInfo.Name, stringBuilder.ToString(), mode == TestityPersistentListenerMode.EventDefined); menu.AddItem(new GUIContent(formattedMethodName), flag, new GenericMenu.MenuFunction2(TesityEventDrawer.SetEventFunction), new TesityEventDrawer.UnityEventFunction(listener, method.target, method.methodInfo, mode)); }
private void DrawEventListener(Rect rect, int index, bool isactive, bool isfocused) { SerializedProperty arrayElementAtIndex = this.m_ListenersArray.GetArrayElementAtIndex(index); rect.y += 1f; Rect[] rowRects = this.GetRowRects(rect); Rect position = rowRects[0]; Rect position2 = rowRects[1]; Rect rect2 = rowRects[2]; Rect position3 = rowRects[3]; SerializedProperty property = arrayElementAtIndex.FindPropertyRelative("m_CallState"); SerializedProperty mode = arrayElementAtIndex.FindPropertyRelative("m_Mode"); SerializedProperty serializedProperty = arrayElementAtIndex.FindPropertyRelative("m_Arguments"); SerializedProperty serializedProperty2 = arrayElementAtIndex.FindPropertyRelative("m_Target"); SerializedProperty serializedProperty3 = arrayElementAtIndex.FindPropertyRelative("m_MethodName"); Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = Color.white; EditorGUI.PropertyField(position, property, GUIContent.none); EditorGUI.BeginChangeCheck(); GUI.Box(position2, GUIContent.none); EditorGUI.PropertyField(position2, serializedProperty2, GUIContent.none); if (EditorGUI.EndChangeCheck()) { serializedProperty3.stringValue = null; } TestityPersistentListenerMode mode2 = TesityEventDrawer.GetMode(mode); SerializedProperty serializedProperty4; switch (mode2) { case TestityPersistentListenerMode.Object: serializedProperty4 = serializedProperty.FindPropertyRelative("m_ObjectArgument"); break; case TestityPersistentListenerMode.Int: serializedProperty4 = serializedProperty.FindPropertyRelative("m_IntArgument"); break; case TestityPersistentListenerMode.Float: serializedProperty4 = serializedProperty.FindPropertyRelative("m_FloatArgument"); break; case TestityPersistentListenerMode.String: serializedProperty4 = serializedProperty.FindPropertyRelative("m_StringArgument"); break; case TestityPersistentListenerMode.Bool: serializedProperty4 = serializedProperty.FindPropertyRelative("m_BoolArgument"); break; default: serializedProperty4 = serializedProperty.FindPropertyRelative("m_IntArgument"); break; } string stringValue = serializedProperty.FindPropertyRelative("m_ObjectArgumentAssemblyTypeName").stringValue; Type type = typeof(UnityEngine.Object); if (!string.IsNullOrEmpty(stringValue)) { type = (Type.GetType(stringValue, false) ?? typeof(UnityEngine.Object)); } if (mode2 == TestityPersistentListenerMode.Object) { EditorGUI.BeginChangeCheck(); UnityEngine.Object objectReferenceValue = EditorGUI.ObjectField(position3, GUIContent.none, serializedProperty4.objectReferenceValue, type, true); if (EditorGUI.EndChangeCheck()) { serializedProperty4.objectReferenceValue = objectReferenceValue; } } else { if (mode2 != TestityPersistentListenerMode.Void && mode2 != TestityPersistentListenerMode.EventDefined) { EditorGUI.PropertyField(position3, serializedProperty4, GUIContent.none); } } EditorGUI.BeginDisabledGroup(serializedProperty2.objectReferenceValue == null); EditorGUI.BeginProperty(rect2, GUIContent.none, serializedProperty3); GUIContent content; if (EditorGUI.showMixedValue) { content = new GUIContent("Temp"); //MODIFIED: EditorGUI.mixedValueContent; } else { StringBuilder stringBuilder = new StringBuilder(); if (serializedProperty2.objectReferenceValue == null || string.IsNullOrEmpty(serializedProperty3.stringValue)) { stringBuilder.Append("No Function"); } else { if (!TesityEventDrawer.IsPersistantListenerValid(this.m_DummyEvent, serializedProperty3.stringValue, serializedProperty2.objectReferenceValue, TesityEventDrawer.GetMode(mode), type)) { string arg = "UnknownComponent"; UnityEngine.Object objectReferenceValue2 = serializedProperty2.objectReferenceValue; if (objectReferenceValue2 != null) { arg = objectReferenceValue2.GetType().Name; } stringBuilder.Append(string.Format("<Missing {0}.{1}>", arg, serializedProperty3.stringValue)); } else { stringBuilder.Append(serializedProperty2.objectReferenceValue.GetType().Name); if (!string.IsNullOrEmpty(serializedProperty3.stringValue)) { stringBuilder.Append("."); if (serializedProperty3.stringValue.StartsWith("set_")) { stringBuilder.Append(serializedProperty3.stringValue.Substring(4)); } else { stringBuilder.Append(serializedProperty3.stringValue); } } } } content = new GUIContent("Temp"); //MODIFIED: GUIContent.Temp(stringBuilder.ToString()); } if (GUI.Button(rect2, content, EditorStyles.popup)) { TesityEventDrawer.BuildPopupList(serializedProperty2.objectReferenceValue, this.m_DummyEvent, arrayElementAtIndex).DropDown(rect2); } EditorGUI.EndProperty(); EditorGUI.EndDisabledGroup(); GUI.backgroundColor = backgroundColor; }