Skip to content

Commit

Permalink
1.8.13 - improved owner/master checks
Browse files Browse the repository at this point in the history
added OnOwnershipRequest overrides to both the Master script and the videoplayer script
changed how checking is done when trying to change a url from a flat owner check, to a master/owner check depending what mode the player is in.
  • Loading branch information
ChildoftheBeast authored Aug 1, 2021
1 parent 1cb427a commit f087859
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
14 changes: 14 additions & 0 deletions MasterOnly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ private void Start()

}

public override bool OnOwnershipRequest(VRCPlayerApi requestingPlayer, VRCPlayerApi requestedOwner)
{
if (syncedMasterOnly)
{
if (requestedOwner.isMaster) return false;
if (requestingPlayer.isMaster) return true;
}
else
{
return true;
}
return false;
}

public void MasterToggleButton() //Call RunProgram on this method
{
Debug.Log("[UdonVR] MasterToggle!");
Expand Down
34 changes: 30 additions & 4 deletions UdonSyncVideoPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ private void Start()
{
}

public override bool OnOwnershipRequest(VRCPlayerApi requestingPlayer, VRCPlayerApi requestedOwner)
{
if (MasterOnlyScript.syncedMasterOnly)
{
if (requestedOwner.isMaster) return false;
if (requestingPlayer.isMaster) return true;
} else
{
return true;
}
return false;
}

public void Init()
{
if (Networking.LocalPlayer != null)
Expand Down Expand Up @@ -227,11 +240,24 @@ private void SetVideoModeVRCUnity()

public void ChangeVideoUrlVRC(VRCUrl url)
{
if (!Networking.IsOwner(gameObject)) return;
if (url.Get() != "" && url != _syncedURL)
if (MasterOnlyScript.syncedMasterOnly)
{
if (Networking.IsMaster && Networking.IsOwner(gameObject))
{
if (url.Get() != "" && url != _syncedURL)
{
_syncedURL = url;
ChangeVideoUrl();
}
}
} else
{
_syncedURL = url;
ChangeVideoUrl();
if (!Networking.IsOwner(gameObject)) return;
if (url.Get() != "" && url != _syncedURL)
{
_syncedURL = url;
ChangeVideoUrl();
}
}
}

Expand Down

0 comments on commit f087859

Please sign in to comment.