Skip to content

Commit 5a19be3

Browse files
committed
fix SyncMode on MenSharp.Statics to None
1 parent 818b9cd commit 5a19be3

3 files changed

Lines changed: 37 additions & 9 deletions

File tree

‎Cargo.lock‎

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

‎tests/unity-project/Assets/Tests/Editor/MenSharpIntegrationTests.cs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,14 @@ public IEnumerator GeneratedProgramsExecuteInTheSdkUdonVm()
184184

185185
// a static field is one for every instance (issue: each instance
186186
// counted from 0), through the holder the scene carries
187-
Assert.IsNotNull(GameObject.Find(MenSharpProxy.StaticsHolderName), "no statics holder in the scene");
187+
GameObject holderObject = GameObject.Find(MenSharpProxy.StaticsHolderName);
188+
Assert.IsNotNull(holderObject, "no statics holder in the scene");
189+
// the holder has no synced variables and never networks: it must sync
190+
// None, not the Continuous a fresh UdonBehaviour defaults to
191+
Assert.AreEqual(
192+
VRC.SDKBase.Networking.SyncType.None,
193+
holderObject.GetComponent<UdonBehaviour>().SyncMethod,
194+
"the statics holder should sync None");
188195
UdonBehaviour second = FindUdon("MenSharpRuntimeSmoke2");
189196
smoke.RunProgram("RunShared");
190197
second.RunProgram("RunShared");

‎unity/io.tesca.mensharp/Editor/MenSharpProxy.cs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ private static UdonBehaviour EnsureStaticsHolder(Scene scene, bool undoable)
278278
}
279279
ApplyVisibility(existing);
280280
ApplySerializedProgram(existing, program);
281+
PinHolderToNoSync(existing, undoable);
281282
root.hideFlags = Reveal ? HideFlags.None : HideFlags.HideInHierarchy;
282283
return existing;
283284
}
@@ -293,10 +294,30 @@ private static UdonBehaviour EnsureStaticsHolder(Scene scene, bool undoable)
293294
holder.programSource = program;
294295
ApplyVisibility(holder);
295296
ApplySerializedProgram(holder, program);
297+
PinHolderToNoSync(holder, undoable);
296298
EditorUtility.SetDirty(holderObject);
297299
return holder;
298300
}
299301

302+
/// The holder carries no synced variables and never networks — Udon
303+
/// statics are one array per scene, read and written locally. A fresh
304+
/// UdonBehaviour defaults its SyncMethod to Unknown, which the inspector
305+
/// shows as Continuous and asks the network manager for a slot it never
306+
/// uses. Pin it to None. Existing holders are corrected on the next sweep.
307+
private static void PinHolderToNoSync(UdonBehaviour holder, bool undoable)
308+
{
309+
if (holder == null || holder.SyncMethod == Networking.SyncType.None)
310+
{
311+
return;
312+
}
313+
if (undoable)
314+
{
315+
Undo.RecordObject(holder, "Set MenSharp statics holder sync mode");
316+
}
317+
holder.SyncMethod = Networking.SyncType.None;
318+
EditorUtility.SetDirty(holder);
319+
}
320+
300321
/// Sets one behaviour-typed public variable, the way TransferValues sets
301322
/// a proxy's fields.
302323
private static void SetBehaviourVariable(UdonBehaviour udon, string name, UdonBehaviour value)

0 commit comments

Comments
 (0)