private static int SortOrderFromAccessMode(ComponentType.AccessMode mode) { switch (mode) { case ComponentType.AccessMode.ReadOnly: return(0); case ComponentType.AccessMode.ReadWrite: return(1); case ComponentType.AccessMode.Subtractive: return(2); default: throw new ArgumentException("Unrecognized AccessMode"); } }
internal static GUIStyle StyleForAccessMode(ComponentType.AccessMode mode) { switch (mode) { case ComponentType.AccessMode.ReadOnly: return(EntityDebuggerStyles.ComponentReadOnly); case ComponentType.AccessMode.ReadWrite: return(EntityDebuggerStyles.ComponentReadWrite); case ComponentType.AccessMode.Subtractive: return(EntityDebuggerStyles.ComponentSubtractive); default: throw new ArgumentException("Unrecognized access mode"); } }
public static string StyleForAccessMode(ComponentType.AccessMode mode) { switch (mode) { case ComponentType.AccessMode.ReadOnly: return(UssClasses.SystemScheduleWindow.Detail.ReadOnlyIcon); case ComponentType.AccessMode.ReadWrite: return(UssClasses.SystemScheduleWindow.Detail.ReadWriteIcon); case ComponentType.AccessMode.Exclude: return(UssClasses.SystemScheduleWindow.Detail.ExcludeIcon); default: throw new ArgumentException("Unrecognized AccessMode"); } }
/// <summary> /// Constructor of the ComponentTypeVisualElement. /// Given an component type, a visual element contains <see cref="CustomToolbarToggle"/> /// and an icon representing its access mode will be created. /// <para><see cref="ComponentType"/>></para>> /// </summary> public ComponentToggleWithAccessMode(ComponentType.AccessMode accessMode) { this.AddToClassList(UssClasses.SystemScheduleWindow.Detail.EachComponentContainer); // Access mode. var componentAccessModeIcon = new Image() { tooltip = accessMode.ToString() }; componentAccessModeIcon.AddToClassList(UssClasses.SystemScheduleWindow.Detail.ComponentAccessModeIcon); componentAccessModeIcon.AddToClassList(EntityQueryUtility.StyleForAccessMode(accessMode)); // Component toggle. ComponentTypeNameToggle = new CustomToolbarToggle(); ComponentTypeNameToggle.AddPreIcon(componentAccessModeIcon); this.Add(ComponentTypeNameToggle); }
public ComponentGroupArrayStaticCache(Type type, EntityManager entityManager, ComponentSystemBase system) { List <int> collection = new List <int>(); List <ComponentType> list2 = new List <ComponentType>(); List <int> list3 = new List <int>(); List <ComponentType> list4 = new List <ComponentType>(); List <ComponentType> list5 = new List <ComponentType>(); foreach (FieldInfo info in type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)) { Type fieldType = info.FieldType; int fieldOffset = UnsafeUtility.GetFieldOffset(info); if (fieldType.IsPointer) { ComponentType.AccessMode accessModeType = (info.GetCustomAttributes(typeof(ReadOnlyAttribute), true).Length != 0) ? ComponentType.AccessMode.ReadOnly : ComponentType.AccessMode.ReadWrite; Type elementType = fieldType.GetElementType(); if (!typeof(IComponentData).IsAssignableFrom(elementType) && (elementType != typeof(Entity))) { throw new ArgumentException($"{type}.{info.Name} is a pointer type but not a IComponentData. Only IComponentData or Entity may be a pointer type for enumeration."); } list3.Add(fieldOffset); list4.Add(new ComponentType(elementType, accessModeType)); } else { bool flag1; if (TypeManager.UnityEngineComponentType != null) { flag1 = TypeManager.UnityEngineComponentType.IsAssignableFrom(fieldType); } else { object unityEngineComponentType = TypeManager.UnityEngineComponentType; flag1 = false; } if (flag1) { collection.Add(fieldOffset); list2.Add(fieldType); } else { if (!(fieldType.IsGenericType && (fieldType.GetGenericTypeDefinition() == typeof(SubtractiveComponent <>)))) { if (!typeof(IComponentData).IsAssignableFrom(fieldType)) { throw new ArgumentException($"{type}.{info.Name} can not be used in a component enumerator"); } throw new ArgumentException($"{type}.{info.Name} must be an unsafe pointer to the {fieldType}. Like this: {fieldType}* {info.Name};"); } list5.Add(ComponentType.Subtractive(fieldType.GetGenericArguments()[0])); } } } if ((list2.Count + list4.Count) > 6) { throw new ArgumentException($"{type} has too many component references. A ComponentGroup Array can have up to {6}."); } this.ComponentDataCount = list4.Count; this.ComponentCount = list2.Count; list4.AddRange(list2); list4.AddRange(list5); this.ComponentTypes = list4.ToArray(); list3.AddRange(collection); this.ComponentFieldOffsets = list3.ToArray(); this.ComponentGroup = system.GetComponentGroupInternal(this.ComponentTypes); this.SafetyManager = entityManager.ComponentJobSafetyManager; this.CachedType = type; }