Skip to content

Commit 44b47e8

Browse files
committed
Add handling for DisableInteractive
1 parent b952ca7 commit 44b47e8

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

Assets/UdonSharp/Editor/UdonSharpExpressionCapture.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ private MethodInfo GetUdonGetMethodInfo()
385385
if (captureProperty.ReflectedType == typeof(VRC.Udon.UdonBehaviour))
386386
{
387387
PropertyInfo property = typeof(Component).GetProperty(captureProperty.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
388+
if (property == null)
389+
property = typeof(VRC.Udon.UdonBehaviour).GetProperty(captureProperty.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
390+
388391
if (property == null)
389392
return null;
390393

@@ -402,10 +405,14 @@ private MethodInfo GetUdonSetMethodInfo()
402405
if (captureProperty.ReflectedType == typeof(VRC.Udon.UdonBehaviour))
403406
{
404407
PropertyInfo property = typeof(Component).GetProperty(captureProperty.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
408+
409+
if (property == null)
410+
property = typeof(VRC.Udon.UdonBehaviour).GetProperty(captureProperty.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
411+
405412
if (property == null)
406413
return null;
407414

408-
return property.GetGetMethod();
415+
return property.GetSetMethod();
409416
}
410417

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

2352-
if (localUdonPropertyName == "enabled")
2359+
if (localUdonPropertyName == "enabled" || localUdonPropertyName == "DisableInteractive")
23532360
foundProperties = _udonEventReceiverProperties.Where(e => e.Name == localUdonPropertyName).ToArray();
23542361

23552362
if (foundProperties.Length == 0)

Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public void SendCustomEventDelayedSeconds(string eventName, float delaySeconds,
7777
/// <param name="eventTiming"></param>
7878
public void SendCustomEventDelayedFrames(string eventName, int delayFrames, VRC.Udon.Common.Enums.EventTiming eventTiming = VRC.Udon.Common.Enums.EventTiming.Update) { }
7979

80+
/// <summary>
81+
/// Disables Interact events on this UdonBehaviour and disables the interact outline on the object this is attached to
82+
/// </summary>
83+
public bool DisableInteractive { get; set; }
84+
8085
public static GameObject VRCInstantiate(GameObject original)
8186
{
8287
return Instantiate(original);

Assets/UdonSharp/Tests/TestScripts/Core/MethodCallsTest.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@ public void ExecuteTests()
104104
tester.TestAssertion("Transform detach parent (null parameter method finding)", transform.parent == null);
105105

106106
transform.SetParent(currentParent);
107+
108+
selfUdon.DisableInteractive = true;
109+
110+
tester.TestAssertion("DisableInteractive true", selfUdon.DisableInteractive);
111+
112+
self.DisableInteractive = false;
113+
114+
tester.TestAssertion("DisableInteractive false", !self.DisableInteractive);
115+
116+
DisableInteractive = true;
117+
118+
tester.TestAssertion("DisableInteractive true 2", DisableInteractive);
119+
120+
DisableInteractive = false;
121+
tester.TestAssertion("DisableInteractive false 2", !DisableInteractive);
107122
}
108123
}
109124
}

0 commit comments

Comments
 (0)