private void GenericMenuSelectionHandler(object menuIndexInfo) { MemberMenuIndex menuIndex = menuIndexInfo as MemberMenuIndex; GetInspectorState(menuIndex.property); PersistentCallData persistentCall = inspectorState.inspectorData.persistentCallData[menuIndex.persistentCallIndex]; if (menuIndex == null || persistentCall.targetProperty.objectReferenceValue == null) { return; } persistentCall.componentIndexProperty.intValue = menuIndex.componentIndex; persistentCall.memberIndexProperty.intValue = menuIndex.memberIndex; persistentCall.isDynamicDataProperty.boolValue = menuIndex.isDynamic; persistentCall.isDynamicProperty.boolValue = menuIndex.isDynamic; // Get the info of the option we selected in the generic menu MemberMenuItem menuItem = persistentCall.genericMenuData.GetComponent(menuIndex.componentIndex).GetMemberItem(menuIndex.memberIndex, menuIndex.isDynamic); // Set target object to reference of component selected in generic dropdown menu persistentCall.targetProperty.objectReferenceValue = (menuIndex.componentIndex < 0) ? persistentCall.targetGameObject : persistentCall.genericMenuData.GetComponent(menuIndex.componentIndex).component; if (menuItem == null) { return; } // Set target object to reference of component selected in generic dropdown menu persistentCall.targetProperty.objectReferenceValue = persistentCall.genericMenuData.GetComponent(menuIndex.componentIndex).component; // Set memberName to string at selectedIndex persistentCall.memberNameProperty.stringValue = menuItem.memberInfo.Name; // Set memberType enum value persistentCall.memberTypeProperty.enumValueIndex = GetMemberTypeIndex(menuItem.memberInfo.MemberType); // Set the function argument type Type argumentType = typeof(void); if (menuItem.memberInfo.MemberType == MemberTypes.Method) { ParameterInfo[] parameterInfo = (menuItem.memberInfo as MethodInfo).GetParameters(); argumentType = parameterInfo.Length == 0 ? typeof(void) : parameterInfo[0].ParameterType; } else if (menuItem.memberInfo.MemberType == MemberTypes.Property) { argumentType = (menuItem.memberInfo as PropertyInfo).PropertyType; } else if (menuItem.memberInfo.MemberType == MemberTypes.Field) { argumentType = (menuItem.memberInfo as FieldInfo).FieldType; } persistentCall.argumentTypeProperty.enumValueIndex = (int)GetArgumentType(argumentType); inspectorState.inspectorData.UpdateDataValues(menuIndex.persistentCallIndex); inspectorState.inspectorData.property.serializedObject.ApplyModifiedProperties(); //TODO? GUIUtility.hotControl = 0; }
private void NoFunctionHandler(object menuIndexInfo) { MemberMenuIndex menuIndex = menuIndexInfo as MemberMenuIndex; if (menuIndex == null) { return; } GetInspectorState(menuIndex.property); // Clear serialized member name and type info PersistentCallData persistentCall = inspectorState.inspectorData.persistentCallData[menuIndex.persistentCallIndex]; persistentCall.componentIndexProperty.intValue = -1; persistentCall.memberNameProperty.stringValue = ""; persistentCall.memberTypeProperty.enumValueIndex = GetMemberTypeIndex(MemberTypes.Method); persistentCall.argumentTypeProperty.enumValueIndex = (int)QuickSupportedTypes.Void; inspectorState.inspectorData.UpdateDataValues(menuIndex.persistentCallIndex); inspectorState.inspectorData.property.serializedObject.ApplyModifiedProperties(); GUIUtility.hotControl = 0; }