Exemple #1
0
        private void    DropDownMultiComponents(Rect r, GameObject gameObject, Object[] values, Type targetType, SerializedProperty property, bool onlyAsset)
        {
            PopupGenericMenu menu = new PopupGenericMenu();

            if (onlyAsset == false)
            {
                this.PrependLastSelectionToMenu(r, menu, property);

                if (PrefabUtility.GetPrefabType(property.serializedObject.targetObject) != PrefabType.None)
                {
                    menu.Add("Revert Value to Prefab", false, false, this.RevertValueToPrefab, property);
                }
            }

            if (gameObject != null)
            {
                Action <object> cb = null;

                if (targetType.IsAssignableFrom(typeof(GameObject)) == true)
                {
                    cb = this.Set;
                }

                menu.Add(gameObject.name, property.objectReferenceValue == gameObject, true, cb, new DataMenu()
                {
                    property = property, target = gameObject
                });
            }

            int offset = menu.Count();

            for (int i = 0; i < values.Length; i++)
            {
                if (values[i] == null)
                {
                    continue;
                }

                Type type = values[i].GetType();

                if (targetType.IsAssignableFrom(type) == true)
                {
                    menu.Add("#" + (i + 1).ToString() + " " + type.Name, property.objectReferenceValue == values[i], true, this.Set, new DataMenu()
                    {
                        property = property, target = values[i], position = r, offset = offset + i
                    });
                }
                else
                {
                    menu.AddDisable("#" + (i + 1).ToString() + " " + type.Name, property.objectReferenceValue == values[i], true, this.Set, new DataMenu()
                    {
                        property = property, target = values[i], position = r, offset = offset + i
                    });
                }
            }

            PopupWindow.Show(r, menu);
        }
Exemple #2
0
        private void    DefaultMenu(Rect r, SerializedProperty property)
        {
            PopupGenericMenu menu = new PopupGenericMenu();

            this.PrependLastSelectionToMenu(r, menu, property);

            if (PrefabUtility.GetPrefabType(property.serializedObject.targetObject) != PrefabType.None)
            {
                menu.Add("Revert Value to Prefab", false, false, this.RevertValueToPrefab, property);
            }

            PopupWindow.Show(r, menu);
        }
Exemple #3
0
 private void    PrependLastSelectionToMenu(Rect r, PopupGenericMenu menu, SerializedProperty property)
 {
     for (int i = 0; i < DragObjectDrawer.lastSelected.Length; i++)
     {
         if (DragObjectDrawer.lastSelected[i] != null)
         {
             menu.Add(DragObjectDrawer.LastSelectedPath + "#" + (i + 1).ToString() + " " + DragObjectDrawer.lastSelected[i].name, false, true, this.DropObject, new DataMenu()
             {
                 property = property, target = DragObjectDrawer.lastSelected[i], position = r, offset = i
             });
         }
     }
     //menu.AddSeparator(string.Empty);
 }