From 7d134358c4fdad1be7e4397b2b64995298f2bad7 Mon Sep 17 00:00:00 2001 From: Merlin <36685500+MerlinVR@users.noreply.github.com> Date: Wed, 17 Mar 2021 23:08:10 -0700 Subject: [PATCH] Add more build validation for sync mode conflicting with position sync --- .../Editor/UdonSharpEditorManager.cs | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/Assets/UdonSharp/Editor/UdonSharpEditorManager.cs b/Assets/UdonSharp/Editor/UdonSharpEditorManager.cs index 7ad4c60e..3157179d 100644 --- a/Assets/UdonSharp/Editor/UdonSharpEditorManager.cs +++ b/Assets/UdonSharp/Editor/UdonSharpEditorManager.cs @@ -532,31 +532,43 @@ static void UpdateSyncModes(List udonBehaviours) } } + if (modificationCount > 0) + EditorSceneManager.MarkAllScenesDirty(); + // Validation for mixed sync modes which can break sync on things foreach (GameObject gameObject in behaviourGameObjects) { UdonBehaviour[] objectBehaviours = gameObject.GetComponents(); - if (objectBehaviours.Length > 1) + bool hasManual = false; + bool hasContinuous = false; + bool hasUdonPositionSync = false; + + foreach (UdonBehaviour objectBehaviour in objectBehaviours) { - bool hasManual = false; - bool hasContinuous = false; + if (objectBehaviour.Reliable) + hasManual = true; + else + hasContinuous = true; - foreach (UdonBehaviour objectBehaviour in objectBehaviours) - { - if (objectBehaviour.Reliable) - hasManual = true; - else - hasContinuous = true; - } +#pragma warning disable CS0618 // Type or member is obsolete + if (objectBehaviour.SynchronizePosition) + hasUdonPositionSync = true; +#pragma warning restore CS0618 // Type or member is obsolete + } - if (hasManual && hasContinuous) + if (hasManual) + { + if (hasContinuous) Debug.LogWarning($"[UdonSharp] UdonBehaviours on GameObject '{gameObject.name}' have conflicting synchronization methods, this can cause sync to work unexpectedly.", gameObject); + + if (gameObject.GetComponent()) + Debug.LogWarning($"[UdonSharp] UdonBehaviours on GameObject '{gameObject.name}' are using manual sync while VRCObjectSync is on the GameObject, this can cause sync to work unexpectedly.", gameObject); + + if (hasUdonPositionSync) + Debug.LogWarning($"[UdonSharp] UdonBehaviours on GameObject '{gameObject.name}' are using manual sync while position sync is enabled on an UdonBehaviour on the GameObject, this can cause sync to work unexpectedly.", gameObject); } } - - if (modificationCount > 0) - EditorSceneManager.MarkAllScenesDirty(); } static bool UdonSharpBehaviourTypeMatches(object symbolValue, System.Type expectedType, string behaviourName, string variableName)