diff --git a/Assets/UdonSharp/Editor/UdonSharpExpressionCapture.cs b/Assets/UdonSharp/Editor/UdonSharpExpressionCapture.cs index 28f074cc..ff416222 100644 --- a/Assets/UdonSharp/Editor/UdonSharpExpressionCapture.cs +++ b/Assets/UdonSharp/Editor/UdonSharpExpressionCapture.cs @@ -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; @@ -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(); @@ -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) diff --git a/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs b/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs index 8c01a7e4..274bff49 100644 --- a/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs +++ b/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs @@ -77,6 +77,11 @@ public void SendCustomEventDelayedSeconds(string eventName, float delaySeconds, /// public void SendCustomEventDelayedFrames(string eventName, int delayFrames, VRC.Udon.Common.Enums.EventTiming eventTiming = VRC.Udon.Common.Enums.EventTiming.Update) { } + /// + /// Disables Interact events on this UdonBehaviour and disables the interact outline on the object this is attached to + /// + public bool DisableInteractive { get; set; } + public static GameObject VRCInstantiate(GameObject original) { return Instantiate(original); diff --git a/Assets/UdonSharp/Tests/TestScripts/Core/MethodCallsTest.cs b/Assets/UdonSharp/Tests/TestScripts/Core/MethodCallsTest.cs index f1fffd2c..94100189 100644 --- a/Assets/UdonSharp/Tests/TestScripts/Core/MethodCallsTest.cs +++ b/Assets/UdonSharp/Tests/TestScripts/Core/MethodCallsTest.cs @@ -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); } } }