Пример #1
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            NSTMaster.EnsureExistsInScene("NST Master").EnsureHasCorrectAdapter();

            var nstsettings = (NSTSettings)target;

            nstsettings.MaxNSTObjects = (uint)System.Math.Pow(2, nstsettings.bitsForNstId);
            nstsettings.frameCount    = (int)System.Math.Pow(2, nstsettings.bitsForPacketCount);

            float adjustedFixedTime = Time.fixedDeltaTime;

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(new GUIContent("Summary:"), "BoldLabel");

            string str =
                "Physics Rate: " + adjustedFixedTime.ToString("0.000") + "ms (" + (1 / adjustedFixedTime).ToString("0.0") + " ticks/sec)\n\n" +

                "You can change the physics rate by changing the Edit/Project Settings/Time/Fixed Step value. \n\n" +

                NSTMapBoundsEditor.WorldBoundsSummary()
            ;

            EditorGUILayout.HelpBox(str, MessageType.None);

            serializedObject.ApplyModifiedProperties();
        }
Пример #2
0
        /// <summary>
        /// Ensures NSTSettings as well as (NSTMaster/MasterAdapter/NetworkIdentity) exist in the scene.
        /// </summary>
        /// <returns></returns>
        public static void EnsureSceneNetLibDependencies(bool immediate = true)
        {
            if (Application.isPlaying)
            {
                return;
            }

            NSTSettings.EnsureExistsInScene();

            // If a post-recompile rebuild of dependencies is pending... do it now.
            TryToAddDependenciesEverywhere();

            if (MasterNetAdapter.NetLib == NetworkLibrary.UNET)
            {
                GetNetworkManager(true);
                CopyPlayerPrefab();
            }

            NSTMaster.EnsureExistsInScene(NSTMaster.DEFAULT_GO_NAME);
            NSTSettings.EnsureExistsInScene(NSTSettings.DEFAULT_GO_NAME);
        }
Пример #3
0
        private void AddAllDependencies(bool silence = false)
        {
            headerName  = HeaderNSTName;
            headerColor = HeaderNSTColor;
            base.OnEnable();

            nst = (NetworkSyncTransform)target;

            // Add this NST to the prefab spawn list (and as player prefab if none exists yet) as an idiot prevention
            if (!Application.isPlaying)
            {
                MasterNetAdapter.AddAsRegisteredPrefab(nst.gameObject, silence);
            }


            // If user tried to put NST where it shouldn't be... remove it and all of the required components it added.
            if (nst.transform.parent != null)
            {
                Debug.LogError("NetworkSyncTransform must be on the root of an prefab object.");
                nst.nstElementsEngine = nst.transform.GetComponent <NSTElementsEngine>();

                NSTNetAdapter.RemoveAdapter(nst);

                DestroyImmediate(nst);

                if (nst.nstElementsEngine != null)
                {
                    DestroyImmediate(nst.nstElementsEngine);
                }

                return;
            }

            nst.na = NSTNetAdapter.EnsureNstAdapterExists(nst.gameObject);

            nst.nstSettings       = NSTSettings.EnsureExistsInScene(NSTSettings.DEFAULT_GO_NAME);
            nst.nstElementsEngine = NSTElementsEngine.EnsureExistsOnRoot(nst.transform, false);
            NSTMaster.EnsureExistsInScene("NST Master");
        }
Пример #4
0
        protected override void Awake()
        {
            // Base does singleton enforcement
            base.Awake();

            NSTMaster.EnsureExistsInScene("NST Master");
            // TODO Add items like this to an idiot check test bool so they can be disabled.
            DestroyAllNSTsInScene();

            // Tell DebugX what the logging choices were.
            DebugX.logInfo     = logTestingInfo;
            DebugX.logWarnings = logWarnings;
            DebugX.logErrors   = true;

            //Calculate the max objects at the current bits for NstId
            MaxNSTObjects = (uint)Mathf.Pow(2, bitsForNstId);

            frameCount =
                (bitsForPacketCount == 4) ? 16 :
                (bitsForPacketCount == 5) ? 32 :
                (bitsForPacketCount == 6) ? 64 :
                0;                 // zero will break things, but it should never happen so breaking it would be good.
        }