File tree Expand file tree Collapse file tree 4 files changed +63
-6
lines changed
NetworkingManagerComponents/Core Expand file tree Collapse file tree 4 files changed +63
-6
lines changed Original file line number Diff line number Diff line change 40
40
<Compile Include =" NetworkedObjectEditor.cs" />
41
41
<Compile Include =" NetworkingManagerEditor.cs" />
42
42
<Compile Include =" Properties\AssemblyInfo.cs" />
43
+ <Compile Include =" ScenePostProcesser.cs" />
43
44
<Compile Include =" TrackedObjectEditor.cs" />
44
45
</ItemGroup >
45
46
<ItemGroup >
Original file line number Diff line number Diff line change
1
+ using System . Collections . Generic ;
2
+ using System . Linq ;
3
+ using MLAPI ;
4
+ using MLAPI . Logging ;
5
+ using UnityEditor . Callbacks ;
6
+ using UnityEngine ;
7
+
8
+ namespace UnityEditor
9
+ {
10
+ public class NetworkScenePostProcess : MonoBehaviour
11
+ {
12
+ [ PostProcessScene ]
13
+ public static void OnPostProcessScene ( )
14
+ {
15
+ List < NetworkedObject > networkedObjects = FindObjectsOfType < NetworkedObject > ( ) . ToList ( ) ;
16
+ networkedObjects . Sort ( ( n1 , n2 ) => CompareSiblingPaths ( GetSiblingsPath ( n1 . transform ) , GetSiblingsPath ( n2 . transform ) ) ) ;
17
+
18
+ for ( int i = 0 ; i < networkedObjects . Count ; i ++ )
19
+ {
20
+ networkedObjects [ i ] . SceneId = ( uint ) i ;
21
+ if ( LogHelper . CurrentLogLevel <= LogLevel . Developer ) LogHelper . LogInfo ( "PostProcessing for object \" " + networkedObjects [ i ] . name +
22
+ "\" completed on scene \" " + networkedObjects [ i ] . gameObject . scene . name +
23
+ "\" with objectSceneId \" " + i + "\" " ) ;
24
+ }
25
+ }
26
+
27
+ private static List < int > GetSiblingsPath ( Transform transform )
28
+ {
29
+ List < int > result = new List < int > ( ) ;
30
+ while ( transform != null )
31
+ {
32
+ result . Add ( transform . GetSiblingIndex ( ) ) ;
33
+ transform = transform . parent ;
34
+ }
35
+
36
+ result . Reverse ( ) ;
37
+ return result ;
38
+ }
39
+
40
+ private static int CompareSiblingPaths ( List < int > l1 , List < int > l2 )
41
+ {
42
+ while ( l1 . Count > 0 && l2 . Count > 0 )
43
+ {
44
+ if ( l1 [ 0 ] < l2 [ 0 ] ) return - 1 ;
45
+ if ( l1 [ 0 ] > l2 [ 0 ] ) return 1 ;
46
+
47
+ l1 . RemoveAt ( 0 ) ;
48
+ l2 . RemoveAt ( 0 ) ;
49
+ }
50
+ return 0 ;
51
+ }
52
+ }
53
+ }
Original file line number Diff line number Diff line change @@ -83,6 +83,9 @@ internal set
83
83
/// </summary>
84
84
public bool isSpawned { get ; internal set ; }
85
85
internal bool ? sceneObject = null ;
86
+ [ HideInInspector ]
87
+ [ SerializeField ]
88
+ public uint ? SceneId = null ;
86
89
87
90
private void OnDestroy ( )
88
91
{
Original file line number Diff line number Diff line change @@ -10,11 +10,10 @@ public enum LogLevel
10
10
Error ,
11
11
Nothing
12
12
}
13
- #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
14
13
15
- internal static class LogHelper
14
+ public static class LogHelper
16
15
{
17
- internal static LogLevel CurrentLogLevel
16
+ public static LogLevel CurrentLogLevel
18
17
{
19
18
get
20
19
{
@@ -25,8 +24,9 @@ internal static LogLevel CurrentLogLevel
25
24
}
26
25
}
27
26
28
- internal static void LogInfo ( string message ) => Debug . Log ( "[MLAPI] " + message ) ;
29
- internal static void LogWarning ( string message ) => Debug . LogWarning ( "[MLAPI] " + message ) ;
30
- internal static void LogError ( string message ) => Debug . LogError ( "[MLAPI] " + message ) ;
27
+ public static void LogInfo ( string message ) => Debug . Log ( "[MLAPI] " + message ) ;
28
+ public static void LogWarning ( string message ) => Debug . LogWarning ( "[MLAPI] " + message ) ;
29
+ public static void LogError ( string message ) => Debug . LogError ( "[MLAPI] " + message ) ;
31
30
}
31
+ #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
32
32
}
You can’t perform that action at this time.
0 commit comments