Exemplo n.º 1
0
        void UpdateAllSystems()
        {
            if (m_systemSortDirty)
            {
                SortSystems();
            }

            // Update all unmanaged and managed systems together, in the correct sort order.
            // The master update list contains indices for both managed and unmanaged systems.
            // Negative values indicate an index in the unmanaged system list.
            // Positive values indicate an index in the managed system list.
            for (int i = 0; i < m_MasterUpdateList.Length; ++i)
            {
                try
                {
                    var index = m_MasterUpdateList[i];

                    if (!index.IsManaged)
                    {
                        // Update unmanaged (burstable) code.
                        SystemState *sys = World.ResolveSystemState(m_UnmanagedSystemsToUpdate[index.Index]);
                        if (sys != null)
                        {
                            if (SystemBase.UnmanagedUpdate(sys, out var details))
                            {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                                var metaIndex       = sys->m_UnmanagedMetaIndex;
                                var systemDebugName = SystemBaseRegistry.GetDebugName(metaIndex);
                                var errorString     = details.FormatToString(systemDebugName);
                                Debug.LogError(errorString);
#endif
                            }
                        }
                    }
                    else
                    {
                        // Update managed code.
                        var sys = m_systemsToUpdate[index.Index];
                        sys.Update();
                    }
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
#if UNITY_DOTSPLAYER
                    // When in a DOTS Runtime build, throw this upstream -- continuing after silently eating an exception
                    // is not what you'll want, except maybe once we have LiveLink.  If you're looking at this code
                    // because your LiveLink dots runtime build is exiting when you don't want it to, feel free
                    // to remove this block, or guard it with something to indicate the player is not for live link.
                    throw;
#endif
                }

                if (World.QuitUpdate)
                {
                    break;
                }
            }
        }
Exemplo n.º 2
0
        internal override void OnStopRunningInternal()
        {
            OnStopRunning();

            foreach (var sys in m_systemsToUpdate)
            {
                if (sys == null)
                {
                    continue;
                }

                if (sys.m_StatePtr == null)
                {
                    continue;
                }

                if (!sys.m_StatePtr->m_PreviouslyEnabled)
                {
                    continue;
                }

                sys.m_StatePtr->m_PreviouslyEnabled = false;
                sys.OnStopRunningInternal();
            }

            for (int i = 0; i < m_UnmanagedSystemsToUpdate.Length; ++i)
            {
                var sys = World.ResolveSystemState(m_UnmanagedSystemsToUpdate[i]);

                if (sys == null || !sys->m_PreviouslyEnabled)
                {
                    continue;
                }

                sys->m_PreviouslyEnabled = false;

                // Optional callback here
            }
        }