Search Unity

Question Unity XR Input: Possible to simulate a InputDevice event via a string?

Discussion in 'VR' started by ConanCheng, Nov 17, 2022.

  1. ConanCheng

    ConanCheng

    Joined:
    Jun 28, 2019
    Posts:
    2
    Unity XR Input: Possible to simulate input events via a fake InputDevice? For example, I input a string "grip" at Input Field(UI), the XRcontroller will grip a object.
    I know a idea come from https://forum.unity.com/threads/uni...put-events-via-a-fake-inputdevice.905738/,but now it seem broken.
    Because the m_xrController.GetType().GetNestedTypes return nothing.

    Code (CSharp):
    1. private Type GetNestedType(object obj, string typeName)
    2.   {
    3.     foreach (var type in m_xrController.GetType().GetNestedTypes(BindingFlags.NonPublic | BindingFlags.Public))
    4.     {
    5.       if (type.Name == typeName)
    6.       {
    7.         return type;
    8.       }
    9.     }
    10.     return null;
    11.   }

    Thanks