/// <summary> /// Not yet documented. /// </summary> public DrawerInfo(Type drawerType, Type drawnValueType, Type drawnAttributeType, OdinDrawerAttribute odinDrawerAttribute) { this.DrawerType = drawerType; this.DrawnValueType = drawnValueType; this.DrawnAttributeType = drawnAttributeType; this.OdinDrawerAttribute = odinDrawerAttribute; // // Figure out the drawer's priority // DrawerPriorityAttribute priorityAttribute = null; if (drawerType.IsGenericType) { // // Special case for Unity property drawers; // Allow them to specify their priority if they // want, and if they haven't, assign them // downgraded priorities so ODIN drawers always // override them by default. // Type unityDrawer = null; if (drawerType.GetGenericTypeDefinition() == typeof(UnityPropertyDrawer <,>) || drawerType.GetGenericTypeDefinition() == typeof(UnityDecoratorAttributeDrawer <, ,>) || drawerType.GetGenericTypeDefinition() == typeof(UnityPropertyAttributeDrawer <, ,>) || drawerType.GetGenericTypeDefinition() == typeof(AbstractTypeUnityPropertyDrawer <, ,>)) { unityDrawer = drawerType.GetGenericArguments()[0]; } if (unityDrawer != null) { priorityAttribute = unityDrawer.GetCustomAttribute <DrawerPriorityAttribute>(); } } if (priorityAttribute == null) { priorityAttribute = drawerType.GetCustomAttribute <DrawerPriorityAttribute>(); } if (priorityAttribute != null) { this.Priority = priorityAttribute.Priority; } if (this.Priority == DrawerPriority.AutoPriority) { if (this.DrawnAttributeType != null) { this.Priority = DrawerPriority.AttributePriority; } else { this.Priority = DrawerPriority.ValuePriority; } } }
private static DrawerPriority CalculateDrawerPriority(Type drawerType) { DrawerPriority priority = DrawerPriority.AutoPriority; // Find a DrawerPriorityAttribute if there is one anywhere and use the priority from that { DrawerPriorityAttribute priorityAttribute = null; if (DrawerIsUnityAlias(drawerType)) { // Special case for Unity property alias drawers; // We should check if their assigned Unity drawer type // itself declares a DrawerPriorityAttribute. priorityAttribute = drawerType.GetGenericArguments()[0].GetCustomAttribute <DrawerPriorityAttribute>(); } if (priorityAttribute == null) { priorityAttribute = drawerType.GetCustomAttribute <DrawerPriorityAttribute>(); } if (priorityAttribute != null) { priority = priorityAttribute.Priority; } } // Figure out the drawer's actual priority if it's auto priority if (priority == DrawerPriority.AutoPriority) { if (drawerType.ImplementsOpenGenericClass(typeof(OdinAttributeDrawer <>))) { priority = DrawerPriority.AttributePriority; } else { priority = DrawerPriority.ValuePriority; } // All Odin drawers are slightly lower priority, so // that user-defined default-priority drawers always // override default-priority Odin drawers. if (drawerType.Assembly == typeof(OdinEditor).Assembly) { priority.Value -= 0.001; } } return(priority); }
/// <summary> /// Indicates the priority of an inspector drawer. /// </summary> /// <param name="super"> /// The super priority. Mostly used by drawers that wants to wrap the entire property but don't draw the actual property. /// These drawers typically don't draw the property itself, and calls CallNextDrawer.</param> /// <param name="wrapper">The wrapper priority. Mostly used by drawers used to decorate properties.</param> /// <param name="value">The value priority. Mostly used by <see cref="OdinValueDrawer{T}"/>s and <see cref="OdinAttributeDrawer{TAttribute, TValue}"/>s.</param> public DrawerPriorityAttribute(double super = 0, double wrapper = 0, double value = 0) { this.Priority = new DrawerPriority(super, wrapper, value); }
/// <summary> /// Indicates the priority of an inspector drawer. /// </summary> /// <param name="priority">Option for priority for the inspector drawer.</param> public DrawerPriorityAttribute(DrawerPriorityLevel priority) { this.Priority = new DrawerPriority(priority); }