Skip to content

Commit 02991bd

Browse files
authored
fix/feat: NI.AssignAuthority sends owner data + Example (#4032)
* fix: NI.AssignAuthority ensures owner data is sent * feat: AssignAuthority example
1 parent 331b4bd commit 02991bd

23 files changed

+3278
-7
lines changed

Assets/Mirror/Core/NetworkIdentity.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,19 @@ public bool AssignClientAuthority(NetworkConnectionToClient conn)
15581558

15591559
clientAuthorityCallback?.Invoke(conn, this, true);
15601560

1561+
// If the connection is already observing the object we need to sync owner data only:
1562+
if (conn.observing.Contains(this))
1563+
{
1564+
foreach (NetworkBehaviour comp in NetworkBehaviours)
1565+
if (comp.syncMode == SyncMode.Owner)
1566+
comp.SetDirty();
1567+
}
1568+
else
1569+
{
1570+
// otherwise rebuild so the owner sees their NI without further delays
1571+
NetworkServer.RebuildObservers(this, false);
1572+
}
1573+
15611574
return true;
15621575
}
15631576

Assets/Mirror/Examples/AssignAuthority.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Mirror/Examples/AssignAuthority/Materials.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 8
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: Object
11+
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
12+
m_ValidKeywords: []
13+
m_InvalidKeywords: []
14+
m_LightmapFlags: 4
15+
m_EnableInstancingVariants: 0
16+
m_DoubleSidedGI: 0
17+
m_CustomRenderQueue: -1
18+
stringTagMap: {}
19+
disabledShaderPasses: []
20+
m_SavedProperties:
21+
serializedVersion: 3
22+
m_TexEnvs:
23+
- _BumpMap:
24+
m_Texture: {fileID: 0}
25+
m_Scale: {x: 1, y: 1}
26+
m_Offset: {x: 0, y: 0}
27+
- _DetailAlbedoMap:
28+
m_Texture: {fileID: 0}
29+
m_Scale: {x: 1, y: 1}
30+
m_Offset: {x: 0, y: 0}
31+
- _DetailMask:
32+
m_Texture: {fileID: 0}
33+
m_Scale: {x: 1, y: 1}
34+
m_Offset: {x: 0, y: 0}
35+
- _DetailNormalMap:
36+
m_Texture: {fileID: 0}
37+
m_Scale: {x: 1, y: 1}
38+
m_Offset: {x: 0, y: 0}
39+
- _EmissionMap:
40+
m_Texture: {fileID: 0}
41+
m_Scale: {x: 1, y: 1}
42+
m_Offset: {x: 0, y: 0}
43+
- _MainTex:
44+
m_Texture: {fileID: 0}
45+
m_Scale: {x: 1, y: 1}
46+
m_Offset: {x: 0, y: 0}
47+
- _MetallicGlossMap:
48+
m_Texture: {fileID: 0}
49+
m_Scale: {x: 1, y: 1}
50+
m_Offset: {x: 0, y: 0}
51+
- _OcclusionMap:
52+
m_Texture: {fileID: 0}
53+
m_Scale: {x: 1, y: 1}
54+
m_Offset: {x: 0, y: 0}
55+
- _ParallaxMap:
56+
m_Texture: {fileID: 0}
57+
m_Scale: {x: 1, y: 1}
58+
m_Offset: {x: 0, y: 0}
59+
m_Ints: []
60+
m_Floats:
61+
- _BumpScale: 1
62+
- _Cutoff: 0.5
63+
- _DetailNormalMapScale: 1
64+
- _DstBlend: 0
65+
- _GlossMapScale: 1
66+
- _Glossiness: 0.5
67+
- _GlossyReflections: 1
68+
- _Metallic: 0
69+
- _Mode: 0
70+
- _OcclusionStrength: 1
71+
- _Parallax: 0.02
72+
- _SmoothnessTextureChannel: 0
73+
- _SpecularHighlights: 1
74+
- _SrcBlend: 1
75+
- _UVSec: 0
76+
- _ZWrite: 1
77+
m_Colors:
78+
- _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1}
79+
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
80+
m_BuildTextureStacks: []

Assets/Mirror/Examples/AssignAuthority/Materials/Object.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Mirror/Examples/AssignAuthority/Prefabs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)