예제 #1
0
        public static void EnsureExistsInScene()
        {
            if (!TickEngineSettings.Single.enableTickEngine)
            {
                return;
            }

            /// Some basic singleton enforcement
            GameObject go = null;

            if (single)
            {
                go = single.gameObject;
            }
            else
            {
                /// Use NetMasterLate go if that singleton exists (this will be rare or never, but just here to cover all cases)
                if (NetMasterLate.single)
                {
                    go = NetMasterLate.single.gameObject;
                }

                single = FindObjectOfType <NetMaster>();
                if (single)
                {
                    go = single.gameObject;
                }
                else
                {
                    // No singletons exist... make a new GO
                    if (!go)
                    {
                        go = new GameObject("Net Master");
                    }

                    single = go.AddComponent <NetMaster>();
                }
            }

            // Enforce singleton for NetMasterLate
            if (!NetMasterLate.single)
            {
                NetMasterLate.single = FindObjectOfType <NetMasterLate>();

                if (!NetMasterLate.single)
                {
                    NetMasterLate.single = go.AddComponent <NetMasterLate>();
                }
            }

            NetMsgCallbacks.RegisterCallback(ReceiveMessage);
        }
예제 #2
0
        public static void EnsureExistsInScene()
        {
            /// Some basic singleton enforcement
            GameObject go = null;

            if (single)
            {
                go = single.gameObject;
            }
            else
            {
                /// Use NetMasterLate go if that singleton exists (this will be rare or never, but just here to cover all cases)
                if (NetMasterLate.single)
                {
                    go = NetMasterLate.single.gameObject;
                }

                single = FindObjectOfType <NetMaster>();
                if (single)
                {
                    go = single.gameObject;
                }
                else
                {
                    // No singletons exist... make a new GO
                    if (!go)
                    {
                        go = new GameObject("Net Master");
                    }

                    single = go.AddComponent <NetMaster>();
                }
            }

            // Enforce singleton for NetMasterLate
            if (!NetMasterLate.single)
            {
                NetMasterLate.single = FindObjectOfType <NetMasterLate>();

                if (!NetMasterLate.single)
                {
                    NetMasterLate.single = go.AddComponent <NetMasterLate>();
                }
            }

            // cached values that don't change
            frameCount     = SimpleSyncSettings.FrameCount;
            frameCountBits = SimpleSyncSettings.FrameCountBits;
            sendEveryXTick = SimpleSyncSettings.SendEveryXTick;

            NetMsgCallbacks.RegisterCallback(ReceiveMessage);
        }