Пример #1
0
        private static void GeneratePopUpForType(GenericMenu menu, UnityEngine.Object target, bool useFullTargetName, SerializedProperty listener, Type[] delegateArgumentsTypes)
        {
            List <UnityEventDrawer.ValidMethodMap> list = new List <UnityEventDrawer.ValidMethodMap>();
            string text = (!useFullTargetName) ? target.GetType().Name : target.GetType().FullName;
            bool   flag = false;

            if (delegateArgumentsTypes.Length != 0)
            {
                UnityEventDrawer.GetMethodsForTargetAndMode(target, delegateArgumentsTypes, list, PersistentListenerMode.EventDefined);
                if (list.Count > 0)
                {
                    menu.AddDisabledItem(new GUIContent(text + "/Dynamic " + string.Join(", ", (
                                                                                             from e in delegateArgumentsTypes
                                                                                             select UnityEventDrawer.GetTypeName(e)).ToArray <string>())));
                    UnityEventDrawer.AddMethodsToMenu(menu, listener, list, text);
                    flag = true;
                }
            }
            list.Clear();
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new Type[]
            {
                typeof(float)
            }, list, PersistentListenerMode.Float);
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new Type[]
            {
                typeof(int)
            }, list, PersistentListenerMode.Int);
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new Type[]
            {
                typeof(string)
            }, list, PersistentListenerMode.String);
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new Type[]
            {
                typeof(bool)
            }, list, PersistentListenerMode.Bool);
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new Type[]
            {
                typeof(UnityEngine.Object)
            }, list, PersistentListenerMode.Object);
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new Type[0], list, PersistentListenerMode.Void);
            if (list.Count > 0)
            {
                if (flag)
                {
                    menu.AddItem(new GUIContent(text + "/ "), false, null);
                }
                if (delegateArgumentsTypes.Length != 0)
                {
                    menu.AddDisabledItem(new GUIContent(text + "/Static Parameters"));
                }
                UnityEventDrawer.AddMethodsToMenu(menu, listener, list, text);
            }
        }
Пример #2
0
        private static void GeneratePopUpForType(GenericMenu menu, UnityEngine.Object target, bool useFullTargetName, SerializedProperty listener, System.Type[] delegateArgumentsTypes)
        {
            List <UnityEventDrawer.ValidMethodMap> methods = new List <UnityEventDrawer.ValidMethodMap>();
            string targetName = !useFullTargetName?target.GetType().Name : target.GetType().FullName;

            bool flag = false;

            if (delegateArgumentsTypes.Length != 0)
            {
                UnityEventDrawer.GetMethodsForTargetAndMode(target, delegateArgumentsTypes, methods, PersistentListenerMode.EventDefined);
                if (methods.Count > 0)
                {
                    menu.AddDisabledItem(new GUIContent(targetName + "/Dynamic " + string.Join(", ", ((IEnumerable <System.Type>)delegateArgumentsTypes).Select <System.Type, string>((Func <System.Type, string>)(e => UnityEventDrawer.GetTypeName(e))).ToArray <string>())));
                    UnityEventDrawer.AddMethodsToMenu(menu, listener, methods, targetName);
                    flag = true;
                }
            }
            methods.Clear();
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[1] {
                typeof(float)
            }, methods, PersistentListenerMode.Float);
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[1] {
                typeof(int)
            }, methods, PersistentListenerMode.Int);
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[1] {
                typeof(string)
            }, methods, PersistentListenerMode.String);
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[1] {
                typeof(bool)
            }, methods, PersistentListenerMode.Bool);
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[1] {
                typeof(UnityEngine.Object)
            }, methods, PersistentListenerMode.Object);
            UnityEventDrawer.GetMethodsForTargetAndMode(target, new System.Type[0], methods, PersistentListenerMode.Void);
            if (methods.Count <= 0)
            {
                return;
            }
            if (flag)
            {
                menu.AddItem(new GUIContent(targetName + "/ "), false, (GenericMenu.MenuFunction)null);
            }
            if (delegateArgumentsTypes.Length != 0)
            {
                menu.AddDisabledItem(new GUIContent(targetName + "/Static Parameters"));
            }
            UnityEventDrawer.AddMethodsToMenu(menu, listener, methods, targetName);
        }