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

Commit

Permalink
Add handling for DisableInteractive
Browse files Browse the repository at this point in the history
  • Loading branch information
MerlinVR committed Jun 5, 2021
1 parent b952ca7 commit 44b47e8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Assets/UdonSharp/Editor/UdonSharpExpressionCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ private MethodInfo GetUdonGetMethodInfo()
if (captureProperty.ReflectedType == typeof(VRC.Udon.UdonBehaviour))
{
PropertyInfo property = typeof(Component).GetProperty(captureProperty.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
if (property == null)
property = typeof(VRC.Udon.UdonBehaviour).GetProperty(captureProperty.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

if (property == null)
return null;

Expand All @@ -402,10 +405,14 @@ private MethodInfo GetUdonSetMethodInfo()
if (captureProperty.ReflectedType == typeof(VRC.Udon.UdonBehaviour))
{
PropertyInfo property = typeof(Component).GetProperty(captureProperty.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

if (property == null)
property = typeof(VRC.Udon.UdonBehaviour).GetProperty(captureProperty.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

if (property == null)
return null;

return property.GetGetMethod();
return property.GetSetMethod();
}

return captureProperty.GetSetMethod();
Expand Down Expand Up @@ -2349,7 +2356,7 @@ private bool HandleLocalUdonBehaviourPropertyLookup(string localUdonPropertyName
{
PropertyInfo[] foundProperties = _componentProperties.Where(e => e.Name == localUdonPropertyName).ToArray();

if (localUdonPropertyName == "enabled")
if (localUdonPropertyName == "enabled" || localUdonPropertyName == "DisableInteractive")
foundProperties = _udonEventReceiverProperties.Where(e => e.Name == localUdonPropertyName).ToArray();

if (foundProperties.Length == 0)
Expand Down
5 changes: 5 additions & 0 deletions Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public void SendCustomEventDelayedSeconds(string eventName, float delaySeconds,
/// <param name="eventTiming"></param>
public void SendCustomEventDelayedFrames(string eventName, int delayFrames, VRC.Udon.Common.Enums.EventTiming eventTiming = VRC.Udon.Common.Enums.EventTiming.Update) { }

/// <summary>
/// Disables Interact events on this UdonBehaviour and disables the interact outline on the object this is attached to
/// </summary>
public bool DisableInteractive { get; set; }

public static GameObject VRCInstantiate(GameObject original)
{
return Instantiate(original);
Expand Down
15 changes: 15 additions & 0 deletions Assets/UdonSharp/Tests/TestScripts/Core/MethodCallsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ public void ExecuteTests()
tester.TestAssertion("Transform detach parent (null parameter method finding)", transform.parent == null);

transform.SetParent(currentParent);

selfUdon.DisableInteractive = true;

tester.TestAssertion("DisableInteractive true", selfUdon.DisableInteractive);

self.DisableInteractive = false;

tester.TestAssertion("DisableInteractive false", !self.DisableInteractive);

DisableInteractive = true;

tester.TestAssertion("DisableInteractive true 2", DisableInteractive);

DisableInteractive = false;
tester.TestAssertion("DisableInteractive false 2", !DisableInteractive);
}
}
}

0 comments on commit 44b47e8

Please sign in to comment.