From 61f725ae03becbadee07ec2ae05b484e46849dfd Mon Sep 17 00:00:00 2001 From: Merlin <36685500+MerlinVR@users.noreply.github.com> Date: Thu, 17 Jun 2021 21:31:07 -0700 Subject: [PATCH] Remove collision transfer option from UdonSharpBehaviours - Remove collision transfer option from UdonSharpBehaviour inspectors and force it to always be false since it is not respected by the client - Fix prefab change recording for sync settings --- .../UdonSharp/Editor/Editors/UdonSharpGUI.cs | 51 +++++-------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/Assets/UdonSharp/Editor/Editors/UdonSharpGUI.cs b/Assets/UdonSharp/Editor/Editors/UdonSharpGUI.cs index 1b4e2162..3d51cf93 100644 --- a/Assets/UdonSharp/Editor/Editors/UdonSharpGUI.cs +++ b/Assets/UdonSharp/Editor/Editors/UdonSharpGUI.cs @@ -16,7 +16,7 @@ namespace UdonSharpEditor { - #region Beta SDK sync mode menu editor + #region Sync mode menu editor internal class SyncModeMenu : EditorWindow { static SyncModeMenu menu; @@ -111,6 +111,8 @@ void SelectIndex(int idx) { Undo.RecordObject(udonBehaviour, "Change sync mode"); udonBehaviour.Reliable = selectedIdx == 1; + + PrefabUtility.RecordPrefabInstancePropertyModifications(udonBehaviour); } Close(); @@ -1427,47 +1429,23 @@ internal static void DrawSyncSettings(UdonBehaviour behaviour) EditorGUILayout.HelpBox("Manual sync cannot be used on GameObjects with VRC Object Sync", MessageType.Error); } - // Position sync upgrade warnings & collision transfer handling -#pragma warning disable CS0618 // Type or member is obsolete EditorGUI.BeginChangeCheck(); - bool newCollisionTransfer = behaviour.AllowCollisionOwnershipTransfer; - if (behaviour.GetComponent() != null) - { - newCollisionTransfer = EditorGUILayout.Toggle(ownershipTransferOnCollisionContent, behaviour.AllowCollisionOwnershipTransfer); - if (newCollisionTransfer) - EditorGUILayout.HelpBox("Collision transfer is currently bugged and can cause network spam that lags your world, use at your own risk.", MessageType.Warning); - } - else if (newCollisionTransfer) + // Position sync upgrade warnings & collision transfer handling +#pragma warning disable CS0618 // Type or member is obsolete + // Force collision ownership transfer off on UdonBehaviours since it is no longer respected when used on UdonBehaviours. + if (behaviour.AllowCollisionOwnershipTransfer) { - newCollisionTransfer = false; - + behaviour.AllowCollisionOwnershipTransfer = false; GUI.changed = true; } - if (EditorGUI.EndChangeCheck()) - { - Undo.RecordObject(behaviour, "Changed ownership transfer"); - behaviour.AllowCollisionOwnershipTransfer = newCollisionTransfer; - } - // For now we'll do a warning, later on we may add a validation pass that just converts everything automatically if (behaviour.SynchronizePosition) { var objectSync = behaviour.GetComponent(); - if (objectSync) - { - if (behaviour.AllowCollisionOwnershipTransfer && !objectSync.AllowCollisionOwnershipTransfer) - { - Undo.RecordObject(behaviour, "Object sync owner transfer"); - objectSync.AllowCollisionOwnershipTransfer = true; - } - - Undo.RecordObject(behaviour, "Change sync position"); - behaviour.SynchronizePosition = false; - } - else + if (!objectSync) { EditorGUILayout.HelpBox("This behaviour has sync position enabled on it, sync position is deprecated and you should now use the VRC Object Sync script.", MessageType.Warning); if (GUILayout.Button("Switch to VRC Object Sync")) @@ -1476,25 +1454,24 @@ internal static void DrawSyncSettings(UdonBehaviour behaviour) while (UnityEditorInternal.ComponentUtility.MoveComponentUp(newObjSync)) { } UdonBehaviour[] behaviours = behaviour.GetComponents(); - - bool usesCollisionTransfer = false; - + foreach (UdonBehaviour otherBehaviour in behaviours) { - usesCollisionTransfer |= otherBehaviour.AllowCollisionOwnershipTransfer; - Undo.RecordObject(behaviour, "Convert to VRC Object Sync"); behaviour.SynchronizePosition = false; behaviour.AllowCollisionOwnershipTransfer = false; } Undo.RecordObject(newObjSync, "Object sync collision transfer"); - newObjSync.AllowCollisionOwnershipTransfer = newCollisionTransfer; + newObjSync.AllowCollisionOwnershipTransfer = false; } } } #pragma warning restore CS0618 // Type or member is obsolete + if (EditorGUI.EndChangeCheck()) + PrefabUtility.RecordPrefabInstancePropertyModifications(behaviour); + EditorGUI.EndDisabledGroup(); }