// TODO this is redudant with NSTNetAdapter code for UNET public static void CopyPlayerPrefabFromPUNtoOthers() { PUNSampleLauncher punl = PUNSampleLauncher.Single; if (!punl || punl.playerPrefab == null) { return; } NSTNetAdapter.AddAsRegisteredPrefab(punl.playerPrefab, true); //// Copy player prefab from PUN launcher to NM //if (MasterNetAdapter.NetLib == NetworkLibrary.UNET) // NSTNetAdapter.AddAsRegisteredPrefab(punl.playerPrefab, true); //// Copy PUN playerPrefab to UNET //NetworkManager nm = GetNetworkManager(MasterNetAdapter.NetLib == NetworkLibrary.UNET); //if (nm && !nm.playerPrefab) //{ // Debug.Log("Copying Player Prefab : <b>'" + punl.playerPrefab.name + "'</b> from " + punl.GetType().Name + " to NetworkManager for you."); // NetworkIdentity ni = punl.playerPrefab.GetComponent<NetworkIdentity>(); // if (!ni) // ni = punl.playerPrefab.AddComponent<NetworkIdentity>(); // // This seemingly pointless code forces the NI to initialize the assetid. For some dumb reason UNET. // ni.assetId.IsValid(); // if (nm.playerPrefab != punl.playerPrefab) // { // nm.playerPrefab = punl.playerPrefab; // EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); // } //} }
// TODO this is redudant with NSTNetAdapter code for UNET public static void CopyPlayerPrefabFromPUNtoOthers() { PUNSampleLauncher punl = PUNSampleLauncher.Single; if (!punl || punl.playerPrefab == null) { return; } NSTNetAdapter.AddAsRegisteredPrefab(punl.playerPrefab, true); }
/// <summary> /// Ensure all required dependencies are added for this NST to work. Can be called often in edit mode, and should be. /// </summary> /// <param name="nst"></param> /// <param name="silence"></param> public static void EnsureAllNSTDependencies(this NetworkSyncTransform nst, SerializedObject serializedObject, bool silence = false) { EnsureSceneNetLibDependencies(); if (Application.isPlaying) { return; } // 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) { XDebug.LogError("NetworkSyncTransform must be on the root of an prefab object."); nst.nstElementsEngine = nst.transform.GetComponent <NSTElementsEngine>(); NSTNetAdapter.RemoveAdapter(nst); Object.DestroyImmediate(nst); if (nst.nstElementsEngine != null) { Object.DestroyImmediate(nst.nstElementsEngine); EditorUtility.SetDirty(nst.gameObject); } return; } nst.nstElementsEngine = NSTElementsEngine.EnsureExistsOnRoot(nst.transform, false); nst.na = EditorUtils.EnsureRootComponentExists <NSTNetAdapter>(nst.gameObject, false); //AddRewindEngine(nst); //// Add this NST to the prefab spawn list (and as player prefab if none exists yet) as an idiot prevention NSTNetAdapter.AddAsRegisteredPrefab(nst.gameObject, true, silence); return; }