UnityEditor.TargetChoiceHandler.AddSetToValueOfTargetMenuItems C# (CSharp) Method

AddSetToValueOfTargetMenuItems() static private method

static private AddSetToValueOfTargetMenuItems ( GenericMenu menu, UnityEditor.SerializedProperty property, TargetChoiceMenuFunction func ) : void
menu GenericMenu
property UnityEditor.SerializedProperty
func TargetChoiceMenuFunction
return void
        internal static void AddSetToValueOfTargetMenuItems(GenericMenu menu, SerializedProperty property, TargetChoiceMenuFunction func)
        {
            SerializedProperty property2 = property.serializedObject.FindProperty(property.propertyPath);
            UnityEngine.Object[] targetObjects = property.serializedObject.targetObjects;
            List<string> list = new List<string>();
            foreach (UnityEngine.Object obj2 in targetObjects)
            {
                string item = "Set to Value of " + obj2.name;
                if (list.Contains(item))
                {
                    int num2 = 1;
                    while (true)
                    {
                        object[] objArray1 = new object[] { "Set to Value of ", obj2.name, " (", num2, ")" };
                        item = string.Concat(objArray1);
                        if (!list.Contains(item))
                        {
                            break;
                        }
                        num2++;
                    }
                }
                list.Add(item);
                menu.AddItem(EditorGUIUtility.TextContent(item), false, new GenericMenu.MenuFunction2(TargetChoiceHandler.TargetChoiceForwardFunction), new PropertyAndTargetHandler(property2, obj2, func));
            }
        }

Usage Example

示例#1
0
 internal static void TargetChoiceField(Rect position, SerializedProperty property, GUIContent label, TargetChoiceHandler.TargetChoiceMenuFunction func)
 {
     EditorGUI.BeginProperty(position, label, property);
     position = EditorGUI.PrefixLabel(position, 0, label);
     EditorGUI.BeginHandleMixedValueContentColor();
     if (GUI.Button(position, EditorGUI.mixedValueContent, EditorStyles.popup))
     {
         GenericMenu menu = new GenericMenu();
         TargetChoiceHandler.AddSetToValueOfTargetMenuItems(menu, property, func);
         menu.DropDown(position);
     }
     EditorGUI.EndHandleMixedValueContentColor();
     EditorGUI.EndProperty();
 }