Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Remove collision transfer option from UdonSharpBehaviours
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
MerlinVR committed Jun 18, 2021
1 parent 1bdf1f6 commit 61f725a
Showing 1 changed file with 14 additions and 37 deletions.
51 changes: 14 additions & 37 deletions Assets/UdonSharp/Editor/Editors/UdonSharpGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -111,6 +111,8 @@ void SelectIndex(int idx)
{
Undo.RecordObject(udonBehaviour, "Change sync mode");
udonBehaviour.Reliable = selectedIdx == 1;

PrefabUtility.RecordPrefabInstancePropertyModifications(udonBehaviour);
}

Close();
Expand Down Expand Up @@ -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<Collider>() != 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<VRC.SDK3.Components.VRCObjectSync>();

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"))
Expand All @@ -1476,25 +1454,24 @@ internal static void DrawSyncSettings(UdonBehaviour behaviour)
while (UnityEditorInternal.ComponentUtility.MoveComponentUp(newObjSync)) { }

UdonBehaviour[] behaviours = behaviour.GetComponents<UdonBehaviour>();

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();
}

Expand Down

0 comments on commit 61f725a

Please sign in to comment.