@@ -34,9 +34,9 @@ private void Awake()
3434 {
3535 /// Remove the UNET NetIdentity if it exists on this object.
3636 var ni = GetComponent < UnityEngine . Networking . NetworkIdentity > ( ) ;
37-
3837 if ( ni )
3938 {
39+ AddMirrorNetManager ( ) ;
4040 DestroyImmediate ( ni ) ;
4141 return ;
4242 }
@@ -73,7 +73,6 @@ static void SceneOpenedCallback(Scene scene, UnityEditor.SceneManagement.OpenSce
7373 if ( ! scene . name . Contains ( "Example" ) && ! scene . name . Contains ( "Sample" ) )
7474 return ;
7575
76- Debug . Log ( "<b>Opening Scene</b> " + scene . name ) ; // // path);
7776 //if (_mode == UnityEditor.SceneManagement.OpenSceneMode.)
7877 // get root objects in scene
7978 List < GameObject > rootObjects = new List < GameObject > ( ) ;
@@ -83,7 +82,7 @@ static void SceneOpenedCallback(Scene scene, UnityEditor.SceneManagement.OpenSce
8382 /// Need to make sure all NetIds have been converted before converting NM
8483 if ( ! mirrorNetIdAlreadyAddedToResources )
8584 {
86- Debug . Log ( "MirrorNetId being added to all resources" ) ;
85+ Debug . Log ( "Mirror NetId being added to all resources that have UNET NetId " ) ;
8786 AddMirrorNetIdToResources ( ) ;
8887 mirrorNetIdAlreadyAddedToResources = true ;
8988 }
@@ -96,7 +95,6 @@ static void SceneOpenedCallback(Scene scene, UnityEditor.SceneManagement.OpenSce
9695 {
9796 if ( mc )
9897 {
99- Debug . Log ( "Found MC on " + go . name ) ;
10098 mc . AddMirrorNetManager ( ) ;
10199 }
102100 }
@@ -105,14 +103,12 @@ static void SceneOpenedCallback(Scene scene, UnityEditor.SceneManagement.OpenSce
105103
106104 public static void AddMirrorNetIdToResources ( )
107105 {
108- Debug . Log ( "LoadAllREsources !!!!" ) ;
109106 // Option for stripping all prefabs in all resource folders of NI
110107 var objs = Resources . LoadAll < MirrorCheck > ( "" ) ;
111108
112109 // MirrorCheck on objects in resource folders should be prefabs. Replace NI on all of those.
113110 for ( int i = 0 ; i < objs . Length ; i ++ )
114111 {
115- Debug . Log ( "<b>Replacing NI on </b>" + objs [ i ] . gameObject . name ) ;
116112 AddMirrorNetowrkIdentity ( objs [ i ] . gameObject ) ;
117113 }
118114
@@ -130,6 +126,7 @@ public static void RemoveUNetNetIdFromResources()
130126 Debug . Log ( "<b>Replacing NI on </b>" + objs [ i ] . gameObject . name ) ;
131127 RemoveUNetNetowrkIdentity ( objs [ i ] . gameObject ) ;
132128 }
129+ AssetDatabase . SaveAssets ( ) ;
133130 }
134131
135132 /// <summary>
@@ -139,13 +136,11 @@ public static void RemoveUNetNetIdFromResources()
139136 public Mirror . NetworkManager AddMirrorNetManager ( )
140137 {
141138 var unetNM = GetComponent < UnityEngine . Networking . NetworkManager > ( ) ;
142- Debug . Log ( "unet nm? " + gameObject . name + " " + ( unetNM != null ) ) ;
143139
144140 if ( unetNM == null )
145141 return null ;
146142
147143 var mirrorNM = GetComponent < Mirror . NetworkManager > ( ) ;
148- Debug . Log ( "mirror nm? " + gameObject . name + " " + ( mirrorNM != null ) ) ;
149144
150145 if ( mirrorNM )
151146 return mirrorNM ;
@@ -245,14 +240,6 @@ public static void AddMirrorNetowrkIdentity(GameObject prefab)
245240 if ( mirrorNI )
246241 return ;
247242
248-
249- ///// TEST
250- //mirrorNI = prefab.AddComponent<Mirror.NetworkIdentity>();
251- //mirrorNI.localPlayerAuthority = unetNI.localPlayerAuthority;
252- //mirrorNI.serverOnly = unetNI.serverOnly;
253- //return;
254-
255-
256243 if ( PrefabUtility . IsPartOfPrefabAsset ( prefab ) )
257244 {
258245 var path = AssetDatabase . GetAssetPath ( prefab ) ;
@@ -266,8 +253,6 @@ public static void AddMirrorNetowrkIdentity(GameObject prefab)
266253 try
267254 {
268255 mirrorNI = prefabRoot . AddComponent < Mirror . NetworkIdentity > ( ) ;
269- Debug . Log ( "Trying " + prefab . name + " " + ( mirrorNI != null ) ) ;
270-
271256 mirrorNI . localPlayerAuthority = unetNI . localPlayerAuthority ;
272257 mirrorNI . serverOnly = unetNI . serverOnly ;
273258 PrefabUtility . SaveAsPrefabAssetAndConnect ( prefabRoot , path , InteractionMode . UserAction ) ;
@@ -293,7 +278,6 @@ public static void RemoveUNetNetowrkIdentity(GameObject prefab)
293278 DestroyImmediate ( unetNI , true ) ;
294279
295280 EditorUtility . SetDirty ( prefab ) ;
296- AssetDatabase . SaveAssets ( ) ;
297281 }
298282
299283 public static void CopyPlayerPrefab ( UnityEngine . Networking . NetworkManager src , Mirror . NetworkManager targ )
0 commit comments