Exemple #1
0
        protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label)
        {
            var eventDrawer = entry.Context.Get(this, "event_drawer", (UnityEditorInternal.UnityEventDrawer)null);

            if (eventDrawer.Value == null)
            {
                eventDrawer.Value = new UnityEditorInternal.UnityEventDrawer();
                this.drawer       = eventDrawer.Value;

                if (UnityPropertyHandlerUtility.IsAvailable)
                {
                    this.propertyHandler = UnityPropertyHandlerUtility.CreatePropertyHandler(this.drawer);
                }
            }

            FieldInfo          fieldInfo;
            SerializedProperty unityProperty = entry.Property.Tree.GetUnityPropertyForPath(entry.Property.Path, out fieldInfo);

            if (unityProperty == null)
            {
                if (UnityVersion.IsVersionOrGreater(2017, 1))
                {
                    this.CallNextDrawer(entry, label);
                    return;
                }
                else if (!typeof(T).IsDefined <SerializableAttribute>())
                {
                    SirenixEditorGUI.ErrorMessageBox("You have likely forgotten to mark your custom UnityEvent class '" + typeof(T).GetNiceName() + "' with the [Serializable] attribute! Could not get a Unity SerializedProperty for the property '" + entry.Property.NiceName + "' of type '" + entry.TypeOfValue.GetNiceName() + "' at path '" + entry.Property.Path + "'.");
                    return;
                }
            }

            base.DrawPropertyLayout(entry, label);
        }
Exemple #2
0
        public static GenericMenu FillUnityContextMenu(SerializedProperty property, GenericMenu genericMenu = null)
        {
            if (EditorGUI_FillPropertyContextMenu != null)
            {
                return((GenericMenu)EditorGUI_FillPropertyContextMenu.Invoke(null, new object[] { property, null, genericMenu }));
            }
            else
            {
                var handler = UnityPropertyHandlerUtility.ScriptAttributeUtility_GetHandler(property);

                if (handler != null)
                {
                    genericMenu = genericMenu ?? new GenericMenu();
                    UnityPropertyHandlerUtility.PropertyHandler_AddMenuItems(handler, property, genericMenu);
                }
            }

            return(genericMenu ?? new GenericMenu());
        }