コード例 #1
0
 internal static void AddSystemToUpdateList(this ComponentSystemGroup self, SystemRefUntyped sysRef)
 {
     self.AddUnmanagedSystemToUpdateList(sysRef);
 }
コード例 #2
0
        private static void AddSystemToRootLevelSystemGroupsInternal(World world, IEnumerable <Type> systemTypesOrig, int managedTypesCountOrig)
        {
            var initializationSystemGroup = world.GetOrCreateSystem <InitializationSystemGroup>();
            var simulationSystemGroup     = world.GetOrCreateSystem <SimulationSystemGroup>();
            var presentationSystemGroup   = world.GetOrCreateSystem <PresentationSystemGroup>();

            var managedTypes   = new List <Type>();
            var unmanagedTypes = new List <Type>();

            foreach (var stype in systemTypesOrig)
            {
                if (typeof(ComponentSystemBase).IsAssignableFrom(stype))
                {
                    managedTypes.Add(stype);
                }
                else if (typeof(ISystemBase).IsAssignableFrom(stype))
                {
                    unmanagedTypes.Add(stype);
                }
                else
                {
                    throw new InvalidOperationException("Bad type");
                }
            }

            var systems = world.GetOrCreateSystemsAndLogException(managedTypes, managedTypes.Count);

            // Add systems to their groups, based on the [UpdateInGroup] attribute.
            foreach (var system in systems)
            {
                if (system == null)
                {
                    continue;
                }

                // Skip the built-in root-level system groups
                var type = system.GetType();
                if (type == typeof(InitializationSystemGroup) ||
                    type == typeof(SimulationSystemGroup) ||
                    type == typeof(PresentationSystemGroup))
                {
                    continue;
                }

                var updateInGroupAttributes = TypeManager.GetSystemAttributes(system.GetType(), typeof(UpdateInGroupAttribute));
                if (updateInGroupAttributes.Length == 0)
                {
                    simulationSystemGroup.AddSystemToUpdateList(system);
                }

                foreach (var attr in updateInGroupAttributes)
                {
                    var group = FindGroup(world, type, attr);
                    if (group != null)
                    {
                        group.AddSystemToUpdateList(system);
                    }
                }
            }

#if !UNITY_DOTSRUNTIME
            // Add unmanaged systems
            foreach (var type in unmanagedTypes)
            {
                SystemHandleUntyped sysHandle = world.Unmanaged.CreateUnmanagedSystem(world, type);

                // Add systems to their groups, based on the [UpdateInGroup] attribute.

                var updateInGroupAttributes = TypeManager.GetSystemAttributes(type, typeof(UpdateInGroupAttribute));
                if (updateInGroupAttributes.Length == 0)
                {
                    simulationSystemGroup.AddUnmanagedSystemToUpdateList(sysHandle);
                }

                foreach (var attr in updateInGroupAttributes)
                {
                    ComponentSystemGroup groupSys = FindGroup(world, type, attr);

                    if (groupSys != null)
                    {
                        groupSys.AddUnmanagedSystemToUpdateList(sysHandle);
                    }
                }
            }
#endif


            // Update player loop
            initializationSystemGroup.SortSystems();
            simulationSystemGroup.SortSystems();
            presentationSystemGroup.SortSystems();
        }
コード例 #3
0
 internal static void AddSystemToUpdateList(this ComponentSystemGroup self, SystemHandleUntyped sysHandle)
 {
     self.AddUnmanagedSystemToUpdateList(sysHandle);
 }