Ejemplo n.º 1
0
        /// <summary>
        /// Add a new ticker with a given delay / interval
        /// </summary>
        /// <param name="del">Delegate to fire after the delay</param>
        /// <param name="delay">Delay until next fire; 0 means "next frame"</param>
        public static void AddTicker(FTickerDelegate del, float delay = 0)
        {
            if (del == null || del.Method == null)
            {
                return;
            }

            if (!FThreading.IsInGameThread())
            {
                FThreading.RunOnGameThread(delegate { AddTicker(del, delay); });
                return;
            }

            FTicker existingTicker;

            if (handlersReverse.TryGetValue(del.Method, out existingTicker))
            {
                RemoveTicker(del);
            }

            FTicker ticker = new FTicker();

            ticker.del = del;
            Native_FTicker.Reg_CoreTicker(IntPtr.Zero, ticker.callback, ref ticker.handle, true, delay);

            handlers[ticker]            = del.Method;
            handlersReverse[del.Method] = ticker;
        }
Ejemplo n.º 2
0
        internal static void OnNativeFunctionsRegistered()
        {
            FTicker.AddTicker(Tick);

            FCoreDelegates.OnBeginFrame.Bind(OnBeginFrame);
            FCoreDelegates.OnEndFrame.Bind(OnEndFrame);
        }
Ejemplo n.º 3
0
        internal static void OnUnload()
        {
            Debug.Assert(FThreading.IsInGameThread(), "Load/hotreload should be on the game thread");
            //if (!FThreading.IsInGameThread())
            //{
            //    FThreading.RunUnloader(delegate { OnUnload(); });
            //    return;
            //}

            Data        = new DataStore();
            IsUnloading = true;

            try
            {
                if (UnloadBegin != null)
                {
                    UnloadBegin();
                }
            }
            catch (Exception e)
            {
                FMessage.Log(ELogVerbosity.Error, "HotReload.UnloadBegin failed. Exception: " + Environment.NewLine + e);
            }

            Engine.FUSharpLatentAction.OnUnload();
            Engine.ManagedLatentCallbackHelper.UnregisterCallbacks();
            StaticVarManager.OnUnload();
            EngineLoop.OnUnload();
            FThreading.OnUnload();
            FTicker.OnUnload();
            IConsoleManager.OnUnload();
            ManagedUnrealTypes.OnUnload();
            GCHelper.OnUnload();

            UnbindNativeDelegates();

            IsUnloaded = true;

            try
            {
                if (UnloadEnd != null)
                {
                    UnloadEnd();
                }
            }
            catch (Exception e)
            {
                FMessage.Log(ELogVerbosity.Error, "HotReload.UnloadEnd failed. Exception: " + Environment.NewLine + e);
            }
        }