Exemplo n.º 1
0
        private static void GetMethodsForTargetAndMode(UnityEngine.Object target, Type[] delegateArgumentsTypes, List <TesityEventDrawer.ValidMethodMap> methods, TestityPersistentListenerMode mode)
        {
            IEnumerable <TesityEventDrawer.ValidMethodMap> enumerable = TesityEventDrawer.CalculateMethodMap(target, delegateArgumentsTypes, mode == TestityPersistentListenerMode.Object);

            foreach (TesityEventDrawer.ValidMethodMap current in enumerable)
            {
                TesityEventDrawer.ValidMethodMap item = current;
                item.mode = mode;
                methods.Add(item);
            }
        }
Exemplo n.º 2
0
        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));
        }