Skip to content

Commit

Permalink
Remove uses of IsValid because null checks work
Browse files Browse the repository at this point in the history
These were used because null checks on UnityEngine.Objects were broken, but this bug has been fixed for a year+ and these calls cause ambiguity and failed compiles in any projects with ShaderGraph imported because Unity made the very poor choice to name a top level namespace 'Utilities'
  • Loading branch information
MerlinVR committed Oct 31, 2022
1 parent 37e1d17 commit 9bfda3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 9 additions & 7 deletions Assets/USharpVideo/Scripts/USharpVideoPlayer.cs
Expand Up @@ -1476,9 +1476,9 @@ public void UnregisterScreenHandler(VideoScreenHandler screenHandler)
}
}

Texture _lastAssignedRenderTexture;
private Texture _lastAssignedRenderTexture;

void UpdateRenderTexture()
private void UpdateRenderTexture()
{
if (_registeredScreenHandlers == null)
return;
Expand All @@ -1490,8 +1490,10 @@ void UpdateRenderTexture()

foreach (VideoScreenHandler handler in _registeredScreenHandlers)
{
if (Utilities.IsValid(handler))
if (handler)
{
handler.UpdateVideoTexture(renderTexture, IsUsingAVProPlayer());
}
}

_lastAssignedRenderTexture = renderTexture;
Expand All @@ -1509,7 +1511,7 @@ void UpdateRenderTexture()
[PublicAPI]
public void RegisterCallbackReceiver(UdonSharpBehaviour callbackReceiver)
{
if (!Utilities.IsValid(callbackReceiver))
if (!callbackReceiver)
return;

if (_registeredCallbackReceivers == null)
Expand All @@ -1531,7 +1533,7 @@ public void RegisterCallbackReceiver(UdonSharpBehaviour callbackReceiver)
[PublicAPI]
public void UnregisterCallbackReceiver(UdonSharpBehaviour callbackReceiver)
{
if (!Utilities.IsValid(callbackReceiver))
if (!callbackReceiver)
return;

if (_registeredCallbackReceivers == null)
Expand Down Expand Up @@ -1559,11 +1561,11 @@ public void UnregisterCallbackReceiver(UdonSharpBehaviour callbackReceiver)
}
}

void SendCallback(string callbackName)
private void SendCallback(string callbackName)
{
foreach (UdonSharpBehaviour callbackReceiver in _registeredCallbackReceivers)
{
if (Utilities.IsValid(callbackReceiver))
if (callbackReceiver)
{
callbackReceiver.SendCustomEvent(callbackName);
}
Expand Down
3 changes: 1 addition & 2 deletions Assets/USharpVideo/Scripts/VideoControlHandler.cs
Expand Up @@ -5,7 +5,6 @@
using UnityEngine.UI;
using VRC.SDK3.Components;
using VRC.SDKBase;
using VRC.Udon;

namespace UdonSharp.Video
{
Expand Down Expand Up @@ -130,7 +129,7 @@ void UpdateMaster()
if (masterField)
{
VRCPlayerApi owner = Networking.GetOwner(gameObject);
if (Utilities.IsValid(owner))
if (owner != null && owner.IsValid())
masterField.text = Networking.GetOwner(gameObject).displayName;
}
#endif
Expand Down

0 comments on commit 9bfda3c

Please sign in to comment.