Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Rewired - Advanced Input for Unity

Discussion in 'Assets and Asset Store' started by guavaman, Sep 25, 2014.

  1. ImaginationVent

    ImaginationVent

    Joined:
    Feb 18, 2015
    Posts:
    5
    Greetings Guava and Friends!
    I am unsure if this has been addressed, but my searches haven't yielded much (could be my vocabulary). I am trying to find the best method on how to disable a player input from (player 2) while player 1 is selecting his character. Once he has pressed the determined button (confirming his selection), I want to disable their controller and enable palyer2's for the remainder of the scene...

    I wrote a method assigning local variables to both players (ie: player 1 = ReInput.players.GetPlayerID(0); etc...) and then using the isPlaying bool (setting false/true)... Which was unsuccessful as the isPlaying it seems is just a check... Has anyone developed a successful method of achieving this through ReWired? Or am I missing a concept in the documentation? Ideas?
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    Hehe... I need to update the huge mess of controllers picture. A lot of controllers and some systems have been added since then.

    Native keyboard fixes some bugs people have reported with Unity's keyboard system on Windows including sticking keys when held during certain window operations.

    The UserDataStore_PlayerPrefs allows controller assignments to be saved and loaded, which many people have been expecting. As usual, there are caveats on desktop platforms that make it not perfect, but it should work well enough for many scenarios.

    One of the more significant parts of this update is native WebGL support. Now there is much better auto-recognition of devices, especially on Chrome. Any "Standard Gamepad" device should automatically just work now. I've mapped the most common gamepads across 4 OS's and 5 web browsers. Yes, this was a lot of mapping for a few devices as expected. The list is here: http://guavaman.com/projects/rewired/docs/SupportedControllers.html#webgl
     
    Last edited: Jul 21, 2017
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    There are too many ways you could do this. The best way is to stop relying soley on input values coming from Rewired (or any input system) to determine what is allowed to be done. You need to implement a state permission system. This is briefly discussed in this FAQ answer. The absolute simplest form of a permission system is a boolean. if(player2InputAllowed) DoSomething(). Set this flag when Player 2 is allowed to have input or not, then simply don't process the input.

    Other ways to stop input from the Player:
    There is no "block input from this Player" flag.
     
    Last edited: Jul 21, 2017
  4. ImaginationVent

    ImaginationVent

    Joined:
    Feb 18, 2015
    Posts:
    5
    guavaman, you're the man. Now I can stop looking for that non-existent "block input from this Player" bool and just make it myself. Thank you!
     
    guavaman likes this.
  5. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    Thanks for the clarification on the native keyboard support. This is something I will use as default from now one and especially for something like X-Arcade TankStick I would unfortunate to having sticking keys from Unity input.

    I just glossed over the WebGL information the first time. That is really a lot of mapping for each browser plus operating system. The wired XBOX-360 controller seems like the best controller for comparability everywhere (cross platform).

    So with control mapper in a WebGL context can you map all other types of controllers or limited to "standard gamepads"? I was thinking of racing wheel or flight sticks Something simple like CH FlightStick Pro with a limited number of buttons seems like it would map nicely into this context.
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    Indeed. The wired 360 controller is really the standard for all gamepads. It works much universally across all platforms except that OSX requires a driver.

    It is not limited to "standard gamepads." Rewired has always supported anything on WebGL through user mapping. This addition of native input only makes things better because it can get more information about the devices and isn't subject to the limitations of UnityEngine.Input such as the 20 button limit. There isn't any coded limit to the number of buttons in Rewired, so as long as the browser isn't written with an arbitrary limit, all the buttons should work. I haven't tested any HOTAS devices on WebGL. However, there seems to be a rather serious error in hat handling in all browsers. Some browsers simply cannot detect them while others detect them and report them as a single axis with invalid values. This breaks most D-Pads on non-XInput devices. Only through Chrome's implementation of "Standard Gamepad" (Firefox doesn't seem to have one) can these hats actually work, but this requires Google to map the device internally. This an issue that the native input library cannot fix because the bad information is being reported directly from the browser which is as low a level as you can go.
     
  7. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    That should not be a real big problem except if you want to use a 8-way HAT (POV HAT). So that should be very useful for all of the flightsticks.

    Is there any limit within WebGL with regards to how many game controller devices are supported for a single application?
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    I think there is a limit, but like everything, it depends on the browser. I believe Firefox was 4 controllers. Not sure about Chrome, Edge, Opera, or Safari.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    Rewired 1.1.4.0 is available on the Unity Asset Store!

    Be sure to read Updating Rewired before updating.

    Release Notes:

    1.1.4.0:

    Changes:
    - Updated for Unity 2017 compatibility.
    - Added native support for WebGL platform. (Unity 5.0+)
    - Windows Standalone, Raw Input, Direct Input: Added Native Keyboard Handling option.
    - Windows Standalone with Native Keyboard Handling and Native Mouse Handling enabled: Disabling "Ignore Input When App Not In Focus" now allows mouse and keyboard input as well as joystick input when the application is not in focus in a build.
    - Added Use XInput and Support HID Devices options to Windows UWP platform settings in Rewired Input Manager.
    - Rewired Standalone Input Module: Changed to disable all mouse input if no physical mouse is present to match Unity's changes to the Standalone Input Module.
    - UserDataStore_PlayerPrefs: Added options to save and load controller assignments.
    - Player.GetTimedButtonPress, Player.GetTimedButtonPressUp, and negative button variants now accept a time value of 0.
    - Input Behavior Button Short Press Time and Button Long Press Time can now be set to a value of 0.
    - 8-way hats on unrecognized controllers now respect the "Force 4-way Hats" option at the Joystick level.
    - iOS/tvOS: Joystick.name now reports the joystick name as reported by the device instead of "Controller" for MFi controllers.
    - Added new SDL2 controller mappings

    New Controllers with Extended Support:
    - GameSir G3
    - GameSir G3s
    - GameSir G3v
    - GameSir G3w
    - GameSir G4
    - GameSir G4s
    - 8Bitdo RB8-64 N64 Controller
    - Microsoft SideWinder Precision 2
    - TigerGame PS/PS2 Game Controller Adapter

    Modified Controller Definitions:
    - Sony DualShock 4
    - Linux Native: Added variant for changes made in the Ubuntu 17.04 driver.
    - Linux Fallback: Dropped support for Linux Fallback due to the inability to differentiate driver
    versions.
    - Microsoft Xbox One, Linux Native, Linux Fallback: Added matching info for older firmware versions.
    - Microsoft Xbox One, UWP Native: Added mappings when XInput is disabled.
    - Microsoft Xbox 360, UWP Native: Added mappings when XInput is disabled.
    - Logitech F310, UWP Native: Added mappings when XInput is disabled.
    - Logitech F710, UWP Native: Added mappings when XInput is disabled.
    - 8Bitdo NES30: Combined definitions for different connection modes into new definition file.
    - 8Bitdo SNES30: Combined definitions for different connection modes into new definition file.
    - 8Bitdo NES30 Pro: Combined definitions for different connection modes into new definition file.
    - Sony DualShock 2: Combined definitions for different PS2 adapters into one definition file.
    - Added native WebGL mappings for:
    - Microsoft Xbox 360 Controller
    - Microsoft Xbox One Controller
    - Microsoft Xbox One S Controller
    - Sony DualShock 4

    API Changes:
    - Added ReInput.ConfigManager.nativeKeyboardSupport property.
    - Added ReInput.ConfigManager.windowsUWPSupportHIDDevices property.
    - Added UserDataStore_PlayerPrefs.LoadJoystickAssignments property.
    - Added UserDataStore_PlayerPrefs.LoadMouseAssignments property.
    - Added UserDataStore_PlayerPrefs.LoadKeyboardAssignments property.
    - Added ReInput.ConfigHelper.webGLPrimaryInputSource property.

    Bug Fixes:
    - Windows Raw Input, Direct Input, XInput: Eliminated 500 byte memory allocations generated periodically when polling for new devices.
    - Unity 2017.1.b10, .NET 4.6 Experimental Scripting Backend: Fixed issue with method calls made by reflection.
    - Windows 10 Universal, .NET scripting backend: Fixed possible freeze during device enumeration when HID device support enabled in app manifest.
    - Windows 10 Universal, IL2CPP scripting backend: Fixed possible crash when closing app when HID device support enabled in app manifest.
     
    Last edited: Jul 24, 2017
    SAM-tak and Dwight_Everhart like this.
  10. Ben_dc

    Ben_dc

    Joined:
    Jul 24, 2016
    Posts:
    2
    I am having a problem with the AddLastActiveControllerChangedDelegate. I am trying to use it to detect what controller is currently being used so I can update the ui prompts to display the correct prompts. However, the callback only fires when it is first assigned and never again. Perhaps I am misunderstanding how to set up the callback? Here is my setup:


    Code (CSharp):
    1.        
    2. private void Awake()
    3. {
    4.         Player.controllers.AddLastActiveControllerChangedDelegate(SetCurrentController());
    5. }
    6.  
    7. /// ... ///
    8.  
    9. private PlayerActiveControllerChangedDelegate SetCurrentController()
    10. {  
    11.          Controller controller = Player.controllers.GetLastActiveController();
    12.          Debug.Log("Current controller is " + controller.name);
    13. }
    14.  
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    I don't even understand how this is compiling. SetCurrentController never returns any value even though you've declared it with a PlayerActiveControllerChangedDelegate return type. That shouldn't compile. Regardless, that's not how you create a delegate in C#. Tutorial

    Remove the () which is telling it to invoke the method instead of passing the method as a delegate which is why it's being called when that line executes.

    Code (csharp):
    1. Player.controllers.AddLastActiveControllerChangedDelegate(OnActiveControllerChanged);
    The method signature is wrong also. It should return a void and take a Player and Controller argument which is the new active controller. This signature is defined by the PlayerActiveControllerChangedDelegate delegate type:

    Code (csharp):
    1. private void OnActiveControllerChanged(Player player, Controller controller) {
    2.     Debug.Log("Current controller is " + controller.name);
    3. }
    Always unsubscribe or else you will leave a hanging reference which will prevent your class from being disposed when you destroy it:
    Code (csharp):
    1. void OnDestroy() {
    2.     if(!ReInput.isReady) return; // because Unity may destroy Rewired before this object on application exit
    3.     Player.controllers.RemoveLastActiveControllerChangedDelegate(OnActiveControllerChanged);
    4. }
     
    Last edited: Jul 24, 2017
  12. Ben_dc

    Ben_dc

    Joined:
    Jul 24, 2016
    Posts:
    2
    Thanks for the quick help guavaman. Part of the issue was that in posting the question I cut out some code that made things a bit more confusing.

    Anyway, got things up and running thanks to your help. Here is the fixed up code if anyone has issues with this in the future:

    Code (CSharp):
    1.    
    2.  
    3. private Player _player;
    4. private PlayerActiveControllerChangedDelegate OnActiveControllerChanged;
    5.  
    6. private void Awake()
    7. {
    8.     _player = ReInput.players.GetPlayer(playerId);
    9.  
    10.     OnActiveControllerChanged += SetCurrentController;
    11.     _player.controllers.AddLastActiveControllerChangedDelegate(OnActiveControllerChanged);
    12. }
    13.  
    14. private void OnDestroy()
    15. {
    16.     if (!ReInput.isReady) return;
    17.     _player.controllers.RemoveLastActiveControllerChangedDelegate(OnActiveControllerChanged);
    18. }
    19.  
    20. private void SetCurrentController(Player player, Controller controller)
    21. {
    22.     Debug.Log("Current controller is " + controller.name);
    23. }
    24.  
    25.  
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    I'm glad you got it working. But your code is more complex than it needs to be. The below will do the same thing.

    Code (CSharp):
    1. private Player _player;
    2.  
    3. private void Awake()
    4. {
    5.     _player = ReInput.players.GetPlayer(playerId);
    6.     _player.controllers.AddLastActiveControllerChangedDelegate(OnActiveControllerChanged);
    7. }
    8.  
    9. private void OnDestroy()
    10. {
    11.     _player.controllers.RemoveLastActiveControllerChangedDelegate(OnActiveControllerChanged);
    12. }
    13.  
    14. private void OnActiveControllerChanged(Player player, Controller controller)
    15. {
    16.     Debug.Log("Current controller is " + controller.name);
    17. }
    I realized I already added code to ignore calls to Remove... when ReInput is already destroyed so that check is unnecessary too.

    Examples on how to use delegates aren't everywhere delegates are used in the documentation. They are shown in the Getting Input documentation section however: http://guavaman.com/projects/rewired/docs/HowTos.html#get-input
     
    Last edited: Jul 24, 2017
  14. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,301
    Hi, I just installed the latest update today and I'm getting this error:

    [AssemblyUpdater] Assembly reference folder does not exist: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v5.0'
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    .......


    I'm pretty sure it's from Rewired because I looked at the DLL's and some are in fact referencing .NET Core 5.0, which I'm guessing is maybe a mistake? Or is the .NET Core beta a requirement now?
     
  15. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    NOTE: I just installed Rewired 1.1.4 into a brand new project without any problems. Unity 5.6.0f3 PRO on Windows 8.1 PRO.

    (1) What version of Unity are you using? What operating system? What platform are you building for?

    (2) I expect you have followed these instructions already right?

    http://guavaman.com/projects/rewired/docs/Updating.html

    (3) As far as I know NET 4.6 or later are experimental versions.

    Did you change the API compatibility to a lower version of *.NET for the build process?
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    This is an exception thrown by Unity trying to run its API updater checker ([AssemblyUpdater]) on the Windows UWP .NET library. Rewired doesn't do anything with .NETCore unless you build to UWP and even then never in the editor. I moved the UWP libraries out of an optional zip and into the project in Unity 2017. (Yes, all the DLL importer options are set up properly.) Apparently Unity doesn't check if .NETCore is installed before trying to API check the library... There isn't anything I can do to stop this short of pulling these libraries back out of the basic install and putting them back into a zip file. Time to rush out an emergency update undoing everything.... :mad:

    By the way, this exception is purely cosmetic.
     
    Last edited: Jul 25, 2017
    neoshaman likes this.
  17. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,301
    Hehe, sorry for the headache. I deleted the UWP folder and it did indeed stop the error. Thanks for looking into it.
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    Thanks for telling me about it early so I can do something about it before everyone contacts support about it.

    Was it giving you the error continuously? I would expect it to only to it on first import. Perhaps it couldn't run the updater so it keeps queuing it for a check.

    Are you by any chance using Windows 7?
     
    Last edited: Jul 25, 2017
  19. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,301
    It was every time it recompiled. Unity also gets weird about the script updater being in a half-finished state, so it would sometimes just refuse to compile after a while. I'm using Windows 10. And I have the current .NET Core runtime installed, but that is version 4.5; the UWP DLL's seem to be referencing .NET Core 5.0 which I assume is the latest beta.
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    Thanks for the info! I'm trying to figure out what to say in the bug report to Unity.

    I believe .NETCore 5.0 is the first release for UWP apps. I think the current version is 5.3.3. 4.5 is Windows 8 Store I believe.
     
    Last edited: Jul 25, 2017
  21. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    920
    Hi there,
    Perhaps a stupid question but better to ask :p
    I have a touch based game template which i want to publish on Amazon Fire TV, what i want is looking for a Input Plugin that if i use automatically make it work with their controller?
    Please advise
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    Rewired supports the Amazon Fire TV controller: Supported Controllers

    However Rewired is not going to make anything work automatically without proper setup. You have to configure all your input settings (Controller Maps, etc.) in the Rewired Input Manager and code your scripts to get input from a Rewired Player.

    Try the free trial first and see if it works for you. Read the documentation to begin.
     
  23. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    243
    @guavaman Regarding the updater problems, as soon as you file an issue, please, send the number to me so I can take a look immediately.

    Best

    Adriano
     
    Dwight_Everhart likes this.
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    Hi Adriano,

    Case 934962. Thanks for looking into this so quickly. The report includes 2 different exceptions, both thrown by UWP NETCore DLL's in the Unity editor. The API updater one is more serious, the other being just cosmetic and happens only once.

    Thanks!
     
  25. skudfisher1

    skudfisher1

    Joined:
    Jul 30, 2013
    Posts:
    5
    Having an issue right now with Unity 2017.1.03f (and latest Rewired) where Unity will just freeze up when I hit play? It's only happening on one machine here but basically I need to Ctrl-Alt-Del and restart Unity 50% of the time I hit play. If I disable the input manager it stops. Also making a completely empty project and adding only Rewired and an object with input manager on it and hitting play does the same thing (although with less frequency it seems?).

    Any idea what it might be? I realize this is a tricky thing to sort out. I have an xbox one controller attached to Windows 7 but it's happening even when I unplug the controller.

    Thanks!

    Edit: Wanted to add I have been using Rewired for years now and never had a problem once until now
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    A problem like this is very likely to require a ton of back and forth. Please contact me via email (there's a support form on the website). I PM'd you my support email address.

    1) Does it happen in a build or only the editor?
    2) What are your Rewired Input Manager -> Settings -> Windows settings?
    3) Disable Native Mouse Handling and retry. (Assuming it's enabled.)
    4) Disable Native Keyboard Handling and retry. (Assuming it's enabled.)
    5) Disable XInput and retry. (Assuming it's enabled.)
    6) If using Raw Input, switch to Direct Input and retry.
    7) If using Direct Input, switch to Raw Input and retry.
    8) Is anything in the log?
     
    Last edited: Jul 25, 2017
  27. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    @guavaman

    It looks like your updated Rewired 1.1.4.1 just arrived in the asset store.
     
    guavaman likes this.
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    The issue reported by @skudfisher1 above turned out to be a bug introduced in 1.1.4.0 that affects XInput and Direct Input. I've released Rewired 1.1.4.2 that fixes this bug. The update is available immediately for registered users. If you'd like to register to receive early access to updates, please contact me here. I've uploaded it to the Unity Asset Store. Hopefully it will go live relatively quickly.

    If you're using 1.1.4.0 or 1.1.4.1, definitely update to 1.1.4.2 because this issue can affect builds as well as the editor.

    As always, be sure to read Updating Rewired before updating.

    1.1.4.2:

    Bug Fixes:
    - Windows Standalone: Fixed potential freeze on start when using Direct Input or XInput introduced in 1.1.4.0.
    - Fixed missing Trigger in HOTAS template for Microsoft Sidewinder Precision 2.
     
    Dwight_Everhart likes this.
  29. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    Thanks for the quick fix.
     
  30. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    489
    So this is a weird case, but I'm trying to copy the Assembly-CSharp.dll from the projects Library folder to a standalone builds Managed folder. The reasoning is my builds take too long, which slows down development by quite a bit. I have to do builds because its a multiplayer client/server game. I'm following this threads instructions in doing so:
    http://answers.unity3d.com/question...ne-even-for-in-editor-buil.html#answer-658285

    The problem is that Rewired throws a long stream of errors that match the following:
    Stack Trace: at Rewired.InputManager_Base.DoUpdate (UpdateLoopType updateLoopType) [0x00000] in <filename unknown>:0
    ------- Rewired System Info -------
    Unity version: 5.6.2f1
    Rewired version: 1.0.0.106.U5
    Platform: Windows
    Using Unity input: False
    Primary input source: RawInput
    Use XInput: True
    Use Steam RawInput fix: True
    Native mouse handling: True
    Enhanced device support: True

    UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:LogError(Object)
    Rewired.Logger:LogError(Object, Boolean)
    Rewired.InputManager_Base:HandleException(ExceptionPoint, String, Exception)
    Rewired.InputManager_Base:DoUpdate(UpdateLoopType)
    Rewired.InputManager_Base:Update()

    Do you have any ideas on what is causing this, and if it would be possible to fix it? I'm having a hard time even trying to find the code that is causing this error.
     
  31. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    243
    Hi, thanks for reporting. I am investigating the more serious one (which is not reproducible in latest commit in our repository). I'll find what was the change that fixed it and check whether it is feasible to back port to 2017.1 / 2017.2

    btw: both are APIUpdater related

    Best

    Adriano
     
    Dwight_Everhart and guavaman like this.
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    There's no information in that to tell me what the exception even is. Nothing in Rewired is going to automatically throw any exception because you copy Assembly-CSharp.dll. Rewired does not and cannot reference Assembly-CSharp.dll because it is within a DLL that is built before Assembly-CSharp.dll ever exists. The only cause I can imagine is if you're trying to use a different version of Rewired in the build than you have build the assembly with. If you post the part of the exception before the Stack Trace I might be able to understand more.
     
  33. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    489
    That's all of the error message. I'm not sure what's going on, but I moved the Rewired folder to the Plugins directory instead and now it's working fine.
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    The code that catches and logs exceptions (ExceptionHandler) always outputs:

    "Rewired: An exception occurred during .... Rewired will attempt to continue running." followed by first the exception message and then the stack trace. If only part of this debug line is outputting, then this error is bizarre and I cannot explain it.

    Moving Rewired into Plugins making it work is even more bizarre. That would have no effect on anything except to make the scripts included in Rewired compile in the Assembly-CSharp-firstpass library instead of Assembly-CSharp. There is no scenario I can think of where this would have any effect on the execution of Rewired, especially in the main Update loop. Were you copying the Assembly-CSharp.dll without also copying the Rewired libraries? (Rewired_Core.dll, Rewired_Windows_Lib.dll, etc.) Or perhaps the versions in the build were different from those in the editor?

    All I can see from that exception is that it had an exception immediately in the very beginning of the Update loop in Rewired.InputManager_Base. Without the exception message I can only guess, but there's nothing that could even throw an exception this early into the Update apart from a missing method exception.
     
  35. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    489
    Moving it to Plugins fixed it for me because the only thing I'm currently going to try and update is Assembly-CSharp. It would be nice to be able to update firstpass as well, but it would be way more work I think, and I'll rarely need it updated so I can just do a new build in those occasions.
     
  36. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,301
    Hi, so I have narrowed down another issue I'm having to the Rewired update. This was happening in 1.1.4.0 and is still in 1.1.4.2. It repros by creating a new blank scene with a Rewired Input Manager object in it while in .NET 4.6 mode. Basically, the first time I enter play mode, things are fine, but then the second time I enter play mode, Unity either crashes (in 2017.1.f3) or throws thousands of the exception below (in the newer 2017.1.p1)

    --------------
    Assertion failed: Assertion failed on expression: 'exception != SCRIPTING_NULL'
    --------------
    Couldn't extract exception string from exception (another exception of class 'ArgumentException' was thrown while processing the stack trace)
    ---------------

    and then eventually these exceptions:

    ---------------
    TypeLoadException: Error Loading class
    System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (System.RuntimeTypeHandle type) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Runtime.CompilerServices/RuntimeHelpers.cs:89)
    UnityEditor.EditorAssemblies.ProcessEditorInitializeOnLoad (System.Type type) (at C:/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:136)
    UnityEditor.EditorAssemblies.ProcessInitializeOnLoadAttributes () (at C:/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:162)
    UnityEditor.EditorAssemblies:processInitializeOnLoadAttributes()
    -----------------
    Unloading broken assembly Library/ScriptAssemblies/Assembly-CSharp-Editor.dll, this assembly can cause crashes in the runtime
    -----------------
    TypeLoadException: Error Loading class
    System.RuntimeType.GetMethodsByName (System.String name, System.Reflection.BindingFlags bindingAttr, System.Boolean ignoreCase, System.RuntimeType reflectedType) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/ReferenceSources/RuntimeType.cs:481)
    System.RuntimeType.GetMethodCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) (at /Users/builduser/buildslave/mono/build/mcs/class/referencesource/mscorlib/system/rttype.cs:2825)
    System.RuntimeType.GetMethods (System.Reflection.BindingFlags bindingAttr) (at /Users/builduser/buildslave/mono/build/mcs/class/referencesource/mscorlib/system/rttype.cs:3078)
    UnityEditor.Build.BuildPipelineInterfaces.InitializeBuildCallbacks (UnityEditor.Build.BuildPipelineInterfaces+BuildCallbacks findFlags) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:182)
    -----------------


    It seems like the first time entering then exiting play mode leaves it in some kind of broken state which it can't recover from; I'm unable to enter play mode again from any scene (regardless of the presence of an InputManager) after that first time of pressing play with an InputManager.
     
    Last edited: Jul 27, 2017
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    See these two posts above for this same issue:

    https://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/page-66#post-3116639
    https://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/page-66#post-3116993

    Short version: Unity/Mono error. Don't use .Net 4.6 Experimental back-end. It's already been reported to Unity.
     
  38. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,301
    Doh, missed those posts. It's weird because I'm almost positive I had it working fine with .NET 4.6 in the earlier betas of 2017.1, and I think they must have broke it for the final release version of 2017.1.

    Unfortunately I'm kind of invested in using the .NET 4 backend; is there any way to skip the dynamic assembly reflection if I'm only building for Windows Standalone? I haven't really looked at the code yet.
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    Nope. The only way would be to disable native input and use Unity as the input source. Rewired was written a long time ago and it would be a very large effort to gut it and restructure everything to work around this bug. :eek: Imagine prescient coding where you see what bugs will appear 3 years from now so you can make different choices...mmm spice... I've been reading Dune Messiah. :p (no spoilers!)
     
  40. AttilioC

    AttilioC

    Joined:
    Jun 29, 2014
    Posts:
    84
    Hi there!

    I've recently updated to Unity 2017.1 and I'm on the latest version of Rewired.

    Today for some reason I started seeing this error in the console:

    Rewired: Exception occurred while creating thread!
    System.NullReferenceException: Object reference not set to an instance of an object
    at Rewired.Utils.Classes.Utility.ThreadHelper.ResetTimeout () [0x00000] in <filename unknown>:0
    at Rewired.Utils.Classes.Utility.ThreadHelper.EVCopEWQChvSOFdbjxTQxjAjIABA () [0x00000] in <filename unknown>:0
    at Rewired.Utils.Classes.Utility.ThreadHelper..ctor (Int32 fixedTimeStepFPS, Boolean useHighPrecisionTimer, Int32 timeoutMS) [0x00000] in <filename unknown>:0
    at Rewired.Utils.Classes.Utility.ThreadHelper.CreateFixedTimeStep (Int32 timeStepFPS, Boolean useHighPrecisionTimer, Int32 timeoutMS) [0x00000] in <filename unknown>:0
    at Rewired.Utils.Classes.Utility.ThreadHelper.CreateFixedTimeStep (Int32 timeStepFPS, Int32 timeoutMS) [0x00000] in <filename unknown>:0
    at Rewired.Utils.Classes.Utility.ThreadedMessageQueue`1[lIGmhkXQjVawfzLRgrFtfozArge+oGoAabDZUKFIFGqSpZOLTmsUkECK].wgEkVJJGLajtDcsfMPgSFrbgWEVO () [0x00000] in <filename unknown>:0

    I'm not sure what causes it, it seems pretty random. I'm playing with a XBOX360 wired gamepad connected on a Macbook Pro if that helps. I'm using the stable scripting runtime (.NET 3.5 equivalent).

    Could you let me know how to fix this?

    Cheers!
     
  41. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    This is Rewired 1.1.4.2 correct? (This Rewired version is not on the asset store yet but announced here and can be downloaded directly from the Rewired developer's website).

    https://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/page-67#post-3160864
     
  42. AttilioC

    AttilioC

    Joined:
    Jun 29, 2014
    Posts:
    84
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    At what point is this occurring? Looking at the source code, it is impossible for there to be a null reference in that method because the only object that could possibly be null is created in the static constructor and never destroyed. This has to be a Mono on OSX bug. I'm going to have to make some kind of workaround.
     
  44. AttilioC

    AttilioC

    Joined:
    Jun 29, 2014
    Posts:
    84
    Hey!

    Mmm unfortunately I can't seem to find a particular cause or reproduction steps. It's usually 3 or 4 seconds after gameplay starts.
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    I will PM you a new build in a few minutes.
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    Rewired 1.1.5.0 is now available for registered users to download immediately. If you would like to receive early access to updates, please contact me here. It will be submitted to the Unity Asset Store when 1.1.4.2 is approved.

    Please read Updating Rewired before updating.

    Important:
    With this update, the Steam Controller and Steam Streaming controllers can be used on OSX using the Native input source. It is now no longer necessary or recommended to use the SDL2 input source on Linux or OSX to achieve Steam Controller compatibility. Using the Native input source means a much wider range of controllers are supported including flight sticks, racing wheels, etc., without losing support for the Steam devices.

    There's a new Best Practices page with these guidelines for Steam and all the Steam issues have been all moved to one place in the docs.

    --------------

    1.1.5.0:

    Changes:
    - Added support for MFi gamepads on Windows Standalone, Windows 8.1 Store, and Windows UWP platforms.
    - Added support for pressure-sensitive buttons on Windows Standalone, Windows 8.1 Store, and Windows UWP platforms.
    - OSX Standalone, Native: Added support for Steam emulated controllers.
    - Added Corgi Engine integration pack.
    - Control Mapper: restoreDefaultsDelegate is now called at the end of the OnRestoreDefaultsConfirmed function.

    New Controller Definitions:
    - Steam Controller (non-native)

    Modified Controller Definitions:
    - SteelSeries Stratus XL (MFi): Added Raw Input and Windows UWP mappings.
    - SteelSeries Nimbus (MFi): Added Raw Input and Windows UWP mappings.
    - Horipad Ultimate HIP-047U (MFi): Added Raw Input and Windows UWP mappings.

    Bug Fixes:
    - Windows Standalone, Native Mouse Handling: UnityEngine.Input mouse input events now work in the editor again when Maximize On Play is enabled in Unity 5.6 and Unity 2017.
    - OSX Standalone, Native: Created workaround for Mono bug causing exception to be thrown when using Xbox controllers on some systems.
     
    Dwight_Everhart likes this.
  47. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    Wow another release. Looking forward to trying out the new Corgi Engine integration.

    This seems like a daily Rewired release schedule this week. :):):cool:

    Thanks again for all your hard work!! It is greatly appreciated.
     
    Dwight_Everhart and guavaman like this.
  48. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    @guavaman @reuno

    Thanks again for this integration.

    This Corgi integration works really nicely with Rewired 1.1.5.0. Just did some basic testing of the demo scenes with the XBOX One and XBOX-360 gamepads and little bit with a couple sticks (i.e. CH Products flight controllers). Thanks for including both 1 player and 4 player mappings as part of the integration.

    Still have more testing to do on the flight controllers side and try a full HOTAS setup and map in some flight pedals.

    Seems like a platform game just needs to be played with a Racing Wheel. :) Just need to add a Racing Wheel and see how well that works. I think it should work nicely between the number of buttons, paddle shifters and D-pad on the wheel plus having 3 pedals should cover everything easily.

    The Ship Console would probably work really nicely to so I will try some testing with that after the racing wheel.

    It just wonderful to be able to mix and match any type of controllers you want to with Rewired so easily.

    Have not tried the 4 player Rewired input manager for Corgi yet but that will follow after I finish the other controller mappings. Four players is going to be really fun play too.

    Back to the racing wheel mapping ...
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,884
    Hi,

    As always, you find the most... creative input setups for every genre of game. :D I didn't make default mappings for racing wheels, not sure about HOTAS. If you make the racing wheel mapping, please send it to me and I can update the integration to include that by default.
     
  50. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    @guavaman just grabbed 1.1.4.2 and updated my game to use the new GetButtonTimedPressUp, etc methods for my "hold down" versus "tap" logic. Works exactly the same as the logic I was doing, but with those I was able to get rid of some extra bools and floats and the code is a bit cleaner now.

    Thanks!