Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    No good.

    Same issue.

    I think the VerifyDataIntegrity is not the one causing the issue.

    Exception:
    System.NullReferenceException: Object reference not set to an instance of an object
    at Rewired.ReInput.atCitDwqJJoxOdvZenzpRDMGWUT (Rewired.InputManager_Base ...

    The one i get the null reference has parameters on it.
    I took a look inside the DLL and i think its this line here:
    "ReInput.atCitDwqJJoxOdvZenzpRDMGWUT(this, InitializePlatform, _userData.ConfigVars, _controllerDataFiles, _userData);"

    What could possibly be null in there i wonder.
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Missing custom calculations would result in a runtime exception on a few select controllers. They wouldn't result in this error. This error means one or all of the following are true:

    1. The Hardware Joystick Maps array is null or empty.
    2. The default Hardware Joystick Map is null or missing.
    3. The Joystick Templates array is null or empty.

    I don't see any reason why it wouldn't work to load this scriptable object from an asset bundle. If it does, I can add a public controllerDataFiles setter so you don't have to do it by reflection.
     
    Last edited: Apr 24, 2021
  3. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Just checked it's all there.

    The default is the "Unkown" i made it print the name in the Debug log.
    The HardwareJoystickMaps has 1 item
    The Joystick Templates has 1 item.

    It prints this:
    MicrosoftXbox360
    DualAnalogGamepad
    Unknown

    They both there. :-\

    I am setting the field as you instructed.

    Code (CSharp):
    1.  
    2. Transform inputManager = transform.FindChildByName("Rewired Input Manager");
    3.  Rewired.InputManager im = null;
    4.              
    5. if(inputManager != null)
    6. {
    7.       im = inputManager.GetComponent<Rewired.InputManager>();
    8. }
    9. var data = general_assets.LoadAsset<Rewired.Data.ControllerDataFiles>("NewControllerDataFiles");
    10. var field = typeof(Rewired.InputManager_Base).GetField("_controllerDataFiles", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
    11. if (field != null)
    12. {
    13.         field.SetValue(im, data);
    14. }
    This is just a condensed version of my code, i have more if statements around.
     
    Last edited: Apr 24, 2021
  4. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    You think it's the reflection that is failing?

    I hate to impose on you, but perhaps, could you try to do what i am doing?

    1) Pick a game.....compile is without Rewired as normal.
    2) Make a new unity project (same version as the game)
    3) Install Rewired on it.
    4) Set a GameManager Scene with an hypotetical GameManger Monobehavior with Don't Destroy.
    5) Set the Rewire Input Manager in that game object, set the controlers as you would.
    6) Put the Scene in an AssetBundle.
    7) Try to load everything from code when the game runs, after its built.
    Compile only the C# if you want (it's what i do)

    Its a bit of a big task i know, this is why i don't want to impose.

    But anyway, this is the scenario i have.

    In the InputManager class that comes in the package i added this attribute to mimic what you do in the Code Order in the Project: [UnityEngine.DefaultExecutionOrder(-32000)]

    It works fine for other things, i think it works fine for this purpose too.
    The Initializer and the other things inside your DLL i can't do that obviously.

    Suggestion: perhaps use the attribute inside your DLL so it works regardless of the Unity setting? (flexibility)


    But i think making that field settable might help, at least its one less thing to worry about (Reflection)
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    If setting the field via reflection were failing, you should get a null reference exception when it tries to access the field.

    ControllerDataFiles contains 3 fields:

    Code (csharp):
    1. [SerializeField]
    2. private HardwareJoystickMap defaultHardwareJoystickMap;
    3.  
    4. [SerializeField]
    5. private HardwareJoystickMap[] hardwareJoystickMaps;
    6.  
    7. [SerializeField]
    8. private HardwareJoystickTemplateMap[] joystickTemplates;
    After setting the controller data files field via reflection, get it again via reflection, then log the values of these 3 fields using their public properties:

    JoystickTemplates
    HardwareJoystickMaps
    DefaultHardwareJoystickMap

    And make sure nothing is null or empty.

    I will attempt to set up my own test. I don't see how reflection could be the cause of this.
     
  6. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Tested, it gets the value back alright.

    And yes i agree with you, i have a try catch around all that and no errors happen or anything. :(

    This is so bizarre.

    Thanks for your efforts in this i appreciate it.
     
  7. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    This is the full error just so you have it.

    And yes i am using the Trial version, for testing purposes, altho i already paid Store for the asset the store takes some days to get the transaction done, something with my Country.

    upload_2021-4-23_22-26-42.png
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    @Zorkind

    My asset bundle test works without issue. I made an asset bundle from Assets/Rewired/Data, then deleted the Assets/Rewired/Data folder. The Rewired Input Manager GameObject is disabled initially. Adding this script to a GameObject results in Rewired launching as normal and showing a DS4 connected and recognized.

    Code (csharp):
    1. using System.IO;
    2. using System.Reflection;
    3. using UnityEngine;
    4. using Rewired;
    5.  
    6. public class TestAssetBundle : MonoBehaviour
    7. {
    8.     void Start()
    9.     {
    10.         InputManager_Base inputManager = FindObjectOfType<InputManager_Base>(true);
    11.         if (inputManager == null) throw new System.Exception("Input Manager is null");
    12.         var data = AssetBundle.LoadFromFile(Path.Combine(Application.dataPath, "AssetBundles/rewiredcontrollers")).LoadAsset<Rewired.Data.ControllerDataFiles>("ControllerDataFiles");
    13.         var field = typeof(InputManager_Base).GetField("_controllerDataFiles",  BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
    14.         if (field != null) {
    15.             field.SetValue(inputManager, data, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField, null, System.Globalization.CultureInfo.CurrentCulture);
    16.         }
    17.         inputManager.gameObject.SetActive(true);
    18.     }
    19. }
    The problem is probably in your copy of ControllerDataFiles that you've encoded into an Asset Bundle.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    The function throwing the exception is the very first initialization function in ReInput. It's a long function that initializes the entire system. A null reference in there is impossible to know where it is coming from based on the exception, but very likely it's controller data files itself.

    My Asset Bundle test does not throw this exception.
     
  10. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Hummmm your test case is not exactly how mine is.

    You are using the same project, with the Rewired installed and setup, with the ExecutionOrder set, project settings, etc, etc.

    I am using this in a game compiled with absolutely never haven Rewired installed at all.

    This is suppose to be able to be linked to any game basically.

    I understand what you did with the Reflection using all those extra parameters, i did test with them as well but they are not required.

    About the ControllerDataFiles, there's nothing special, i just add them to the bundle, and load them up, nothing more.

    But as i have said before, my game has absolutely nothing related to Rewired when it's Build.

    No editor settings, references, nothing, a game straight out of Steam if you want.

    Just to be absolutely sure, i used your code.

    Same thing.
     
    Last edited: Apr 24, 2021
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    I can't be of any help then. I know you already know this, but the issues you are having have to be related to either Unity's Asset Database system and/or how you're using it, so there isn't anything I'm going to be able to do to make that particular setup work. Rewired is just scripts, a couple of DLLs, and Unity serialized data. There isn't anything I'm supposed to be doing in a special way to make it work with Asset Bundles.

    What you're trying to do isn't going to work anyway because the Unity Input Manager settings would be missing from your project. On any platform that doesn't use native input entirely for keyboard, mouse, and joysticks will throw exceptions because all the Unity input manager entries are missing which are required for Rewired to get input using UnityEngine.Input.

    I am certainly not an expert with Asset Bundles, but as far as I am aware, Asset Bundles cannot contain code (maybe they can contain DLLs? Definitely not scripts.). How would you load Rewired entirely from an Asset Bundle without any of its code in the project? Rewired is a combination of DLLs and scripts that have to be compiled by Unity. Is everything being loaded via reflection from a .bytes file made from a compiled DLL? I really have no idea what you're doing to get this to even partially work. The null reference exception could easily be a required object instantiated by the C# side of Rewired that does not exist because none of the required scripts exist.
     
    Last edited: Apr 24, 2021
  12. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    You are not understanding how i am working. Which is ok, it's not trivial to explain my workflow in just a couple of lines, but i will try, but first let me correct some things.

    I am only running on Windows, so the only platforms i am interesting in are PC ones x86 / x64

    Asset Bundles have metadata references to scripts, because otherwise it would lose all the Inspector properties you have input in the Game Object you are bundling.

    I am not sure they can have DLLs, would not make much sense IMO but i am not an expert as well.

    Anyway, back to my workflow, like i stated in my first message, this project i am working on is a Mod, which means, i don't get to Rebuild the game.

    I have access to the game C# code, by decompiling (it's how mods work).

    The mod is working just fine, for an absurd number of things i have done to the game.

    The asset bundles serve the purpose of adding assets to the game for me, like Scenes, Prefabs, textures, etc.

    In this particular case, i am loading an entire Scene from Asset Bundle, which contains my GameManager, which is set to not Destroy, after i loaded that gameobject, i dispose of the Scene, and move forward with the flow of the game -> Main Menu -> InGame Scene, etc, etc.

    The Rewired DLLs, i am adding reference in the C# project itself, then copying them to the game folder.

    As you can see, it is a very manual approach, and everything done by code.

    About the UnityEngine.Input, i think i can change the inputs in code as well, i have not yet, because i am trying to make the Rewired to work at least at a minimum capacity, so i know it's working, but i will investigate about this for sure.

    Too little things in Unity can't be done by code, i am confident i can make this work, but i need your help with making the DLL flexible enough to accept this, unfortunately your DLL is obfuscated and i understand the reason why you do it ofc, but because of this, i need you to help me with this, there is no other way, if i could do it myself, believe me i would.

    I want to use your asset in my project but if i can't, i will have to find another asset, my plan was to add as much flexibility as possible into this mod for the 1300+ players waiting for it, but if i can't well, i will search other means to do it.

    This mod is just the first step, i intend on recoding this entire game i am modding on, because it is an Abandonware at the moment and i am the only one willing to take on such a project to keep the game alive, of course in this new Recode i will have full control of the project and be able to use Rewired as you intend it to be used, but for the moment, i need to work this way, wiring things manually via code.

    I hope you understand my motives and my legitimate desire to make this work, i am not here to sabotage, or do any harm, when i say i would change your DLL if i could, is not out of malice, but out of necessity. Unfortunately modding lead us to take the step further and looking under the hood of things, so we can make them work somehow.

    Thanks for all your effort in helping out for the moment, i really hope you can keep helping.

    I will try other things here and see what i can do about all this.
     
  13. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    About UnityEngine.Input, you use Input.GetKey for keyboard maps, correct?

    If i use XInput, or DirectInput, we can overcome the issue of not having the Axes mapped into the Project Settings, right?
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    So all of that information is incredibly important for me to understand what you're doing. Decompiling an existing game so you can add new executable code to it, manually adding DLLs from Rewired to it, etc. None of this information was in your previous messages, so I had no way of knowing how or what to do to reproduce your scenario. I am not a game modder, so I don't know the tools or the workflows that are common to doing something like this. I spent several hours yesterday futzing around trying to set up a project similar to what you described in your previous message without knowing that I was supposed to be decompiling and modifying the existing game code or copying Rewired DLL's into the project. Doing the same thing into a new Unity project didn't work at all, with all MonoBehaviour references being broken. Still missing from this information is just how your are getting the Rewired C# scripts compiled and into this built game. Those are compiled to Assembly-CSharp.dll by Unity. Are you copying this into the project as well? There would already be an Assembly-CSharp.dll in the project from the original game, so are you renaming it? I've tried this and it doesn't work. It says the script reference is broken on Input Manager.

    Basically, I don't have the modding knowledge or the information to reproduce what you are trying to do. I can't really do anything without having the modified game you're working on, a repro project of some sort, or spending many hours to learn Unity mono game modding and set up the environment required to do this through trial and error. I don't think that's a reasonable ask. If you want help with this, I need the project. The only way I'm going to be able to debug this is to make new builds of Rewired adding all kinds of logging to its initialization function to find out exactly what is null.

    You're making the assumption that there's something wrong with the DLL or something that can be changed in the DLL that would fix your problems. I'm am virtually 100% certain this is not the case. There is nothing special about the Rewired DLL. Obfuscation doesn't change the way it fundamentally functions in any way. It simply makes the code hard to read. The Null Reference Exception is happening because something is null that should not be null. What that something is I don't know. And the reason it is null is not because it's a DLL or because it's obfuscated. I'm almost certain something is missing, either from the asset bundle or from the C# assembly.
     
    Last edited: Apr 24, 2021
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Every platform works differently, as does every input source, modified by your chosen options for that platform.

    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms

    If all the default settings are left alone, Windows doesn't need UnityEngine.Input axes in any way. Nor does it use UnityEngine.Input for keyboard keys.
     
  16. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Yes, i have not gave all the information i did in the last post, to me this way of work became such a common thing that i forgot to explain it fully.

    Just out of the bat, no, i am not making assumptions that your DLL is wrong, what i meant, is that if i could "customize" it to my needs, i would. I did not imply it needs "fixing" it works fine for what you intended it to work for, as i have explained in my original post.

    About the MonoBehaviour, and Assembly-CSharp.DLL perhaps i can explain further.

    Yes Unity build that dll when you are Building the entire game in the Editor.

    But i do not use the Editor, i use Visual Studio.

    I can compile the Assembly-CSharp.dll as i need, and yes some times Unity log file will have a lot of warnings you just need to know how to deal with it, as long as it does not affect your game, its fine.

    Like i said, it's a lot of manual code, i am no expecting you to learn anything, or do a lot of work for me in an "unreasonable" manner.

    I can't share the project with you, but i can build a demo game, same way as i have said in my post that you linked in your original message and reproduce the entire scenario.

    But first i want to finish something i am trying here on my end, and if i still can't make it work, then i can create the projects you need to test my workflow on your end.

    It will be comprised basically of:
    1) the demo unity game project
    2) the visual studio project with the same code used in the demo unity game project

    All you have to do is compile the new Assembly-CSharp.dll and place it into the game Manager folder.

    Thats basically it, it's not absurd.

    All i am doing really is not using the Unity Editor, everything else is basically the same.

    If you open the Visual Studio project of any Unity game, and hit BUILD, it will produce an Assembly-CSharp.dll the same way i am doing, there is no magic happening here, just simple Code compilation.

    Rewired scripts are inside this Assembly-CSharp.dll i am building, the same way it would happen if i asked Unity Editor to Compile, there is no difference.
     
  17. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Perfect, then thats how i will do it. :)
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    There has to be an additional critical step missing because it is not working no matter what I try. I have already tried repeatedly to take build DLLs from the Unity csproj, manually built in VS, or built by Unity itself. It doesn't matter. It doesn't work.

    It seems to be that the only possible way the game could load the Rewired_Core.dll, Rewired_Windows.dll, and Assembly-CSharp.dlls is if they are properly referenced from another DLL. What are you doing to force the decompiled game to reference these assemblies? Loading them via reflection does not work. Are you re-compiling the decompiled game in Visual Studio, adding the references there? Or is this a new VS project that references the game's DLLs, Rewired's DLLs, then calls some entry point in the game's DLL?

    After researching some into Unity game modding: Are you using Unity Mod Manager and Harmony to add references to these DLLs? Or some other tools? This would be important information to know. Copying the DLLs into the folder does nothing if they're not referenced by something.

    Rewired's classes cannot be loaded so that the MonoBehaviour reference to the Rewired Input Manager in the Asset Bundle can work without some kind of reference the Rewried_Core.dll, Rewired_Windows.dll, and the built Assembly-CSharp.dll.
     
  19. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Hahaha, i understand your confusion.

    No i am not using any modding strategies people use out there, i am doing this the hard way.

    Just think of this: if a game don't offer modding support out of the box, some one need to add it right? so in the end, they have to do what i do at some point, to make it easier for others, so there is a way to change the code, you just need to decompile the Assembly-CSharp.DLL using ILSpy or any other method, that will create a CPROJ for you.

    Then, you fix the project references by pointing it to the original Game Manager folder, the CPROJ will now compile without errors, if some errors are still around, you fiddle with them, until you get a working project.

    After that is done, you just get the Assembly-CSharp.dll and replace the one in the Manager folder of the game.

    BUT, you don't need to do all this decompile to test this.

    It is not required, as long as you can load the Asset Bundles to a game that never had Rewired into it.

    And thats what i just did and it gives the same error but it seems like your DLL is much more talkative to Unity Editor Debug than without it.

    Basically what i did was, creating a NEW PROJECT.....load the assetbundle.

    Thats it.

    Oh, just to clarify.....i have placed the Rewired libraries in the new Project, and also the Rewired scripts.

    I just didn't run the setup procedures.

    So the game project settings are as if Rewired never existed, default Player Settings, default ExecutionOrders, etc.
     
    Last edited: Apr 24, 2021
  20. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
  21. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    The ControllersDataFiles load correctly and works fine.

    The issue is the Axes as you mentioned. :(

    If there was a way to turn that off somehow. :(
     
  22. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    upload_2021-4-24_16-48-33.png

    You can see the ControllerDataFiles was loaded correctly using the Reflection we did.

    This comes from the assetbundle alright, no issues here.

    It is really the UnityEngine.Input :(
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Well, I was trying that for hours last night. I can easily create a new project, import the asset bundles I created from the first project. I did try copying Rewired_Core.dll and Rewired_Windows.dll into the new project, but the step of copying the built Assembly-CSharp.dll from the first project to the new project always fails because it doesn't seem to be a valid assembly. Unity cannot load the MonoBehaviours from it. This happens whether I take the Assembly-CSharp.dll from the Libraries/ScriptAssemblies folder or if I compile them myself in Visual Studio.

    By placing the Rewired scripts in the project, that of course will work. But I thought the point of this test was to test adding all of this to a game without re-compiling Rewired in any way.

    If you take your test, delete the scripts, and try compiling Assembly-CSharp.dll from another project that contains Rewired, then copying that into this project, you will see the assembly references are broken.

    The exact same thing happens if I follow those same steps in a build from a Unity project that contains nothing but a script to 1) Load the Rewired DLLs and generated Assembly-CSharp.dll into memory via reflection 2) Load the scene from the Asset Bundle. The result is "The referenced script on this Behaviour (Game Object 'Rewired Input Manager') is missing!"
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    The System.ArgumentException about Mouse 0 axis is not the same exception you showed me yesterday. That was a null reference exception.
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Unless Unity changes the exception it throws in builds? I don't think that's the case.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    But yes, it will fail regardless if these Input Manager axes are not set up. Now that I look back at the code, Rewired monitors the Unity mouse for other reasons even when using a native mouse input source on Windows. These input manager entries are not optional. It seems to me this data would be available somewhere in the built game and would need to be modified. My guess would be globalgamemanagers.assets or sharedassets0.assets.
     
  27. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Yeap, my thoughts too.

    About it giving different errors in this image i posted, is due to the fact that the game i am modding prob have its own set of Axes already setup for its internal and horrid input manager.

    The entire reason why i am doing this is to replace this original input manager that exists, it is very limited, and yours is much more flexible.

    The Mouse0 error is because the Unity Project i created is new and has only default settings nothing more. :)

    You think it would be possible to turn this off somehow? a bypass or a way to customize this behavior?
     
  28. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Unity error messages are usually useless after build, outside the Editor.

    This is prob because of settings in the Debug information, perhaps the original game has set it to be low.

    Anyhow, what i do to figure out where an exception has happened, is make a variable with line numbers.

    Just set the variable to a number in each segment of the code and see which was the last number, doing this you can pinpoint the location.

    It is a very old way to debug (ASP 3.0 / PHP) era no debugging in Notepad text editors :p

    But in this case it helps, when you trying to debug a Release code in production.
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    That must be a new thing, because that "MouseAxis" not set up message used to be a telltale signal the user hadn't set up or had overwritten the input manager entries on PS4, Xbox One, and other build targets that rely on UnityEngine.Input.

    https://guavaman.com/projects/rewir...joystick-axes-dont-work-on-fallback-platforms

    This was always reported in builds. Unity's Debug.Log has gotten more options over the years though.

    Sorry. I now completely avoid making changes to my structure or design to accommodate extreme edge case use cases. Using Rewired without installing Input Manager entries was not part of the design of the system. Accommodating these requests has bitten me too many times in the past, requiring me to maintain all manner of things that end up making my code brittle and hard to maintain where I never know what special edge case I might be breaking when I make some kind of change to my system. It's already full of things like this, and I don't want to add anymore things I have to keep track of.

    And in fact, the Unity mouse is used for something even when using native mouse input on Windows. It is used for Mouse.screenPosition, so the code path where I create my thread-safe Unity mouse watcher still needs to execute regardless.

    I'm very old school. I do that all the time too. I rarely use breakpoints or debuggers for anything.
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    The only thing I could do is, if this exception can be caught, make it not completely stop the system from functioning, but always return 0 for Unity mouse deltas, which aren't used when using native mouse input. This error never used to be an exception. It always used to be an error log written by Unity and was not catchable. They obviously changed that at some point.
     
  31. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    I see, well if you can help in anyway possible for me to keep using your asset great deal.

    Otherwise i will have to make my own which i was trying to avoid. :-\

    Thanks for all the help anyway.
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Try this.

    The InputManager_Base.dataFiles property has a public setter now too.
     

    Attached Files:

  33. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Thanks for keep helping, i appreciate.

    Same Null reference error tho.

    Question: Is it possible to make public the Name of the Mouse Axes and Buttons you monitor?

    I set the Mouse inputs as the Error messages were popping in that Demo project, and when i was done with all 6 buttons and 3 axes it went through and initialized without any more errors.

    Since i am positive i have these Mouse inputs in the original game, if i can tell Rewired what the name of the inputs are, it might work.

    You think it is something simple to do, or it would require a big change? if you use string name straight up, just use a property instead, something like that.

    But, what you did in this DLL tho?

    I will try it in the Demo project now to see if i get any change.
     
  34. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Hummmm interesting, in the Demo Project, because i added the MouseButtons in the InputManager in the Project settings, the mouse is being recognized by Rewired.

    But keyboard inputs like pressing W key, is ignored.

    OOOoooops sorry.

    I forgot to enable the Map :p

    I never got this much forward into using the asset hahahaha

    It is working fine.

    All i really need is to find a way to go around the Mouse inputs.

    As for the Null reference in the original game...i am still not sure what it is about.

    Perhaps something is getting in the way, i will investigate further.
     
    Last edited: Apr 25, 2021
  35. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Ok i have news.

    I was able to change the InputManager.asset inside the compiled game.

    I tested it by checking MouseButton0 if it was clicked.

    Worked like a charm.

    BUT !!!!

    The null reference is still there, so now i am 100% positive this is something else entirely.

    Need to figure out what is missing or conflicting with it.

    I will try to add one by one the components existent in the game, into the Demo project.

    I am hoping at some point i will get the Null Reference in it as well.

    But, at least i was able to load the 512 input settings your DLL needs, so progress.

    Hey, you might want to fix this typo ;P

    UnityTools.GetCurrentPlatformResourecesDLLPaths()
     
    Last edited: Apr 25, 2021
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    @Zorkind

    The only way I will be able to solve this and tell you what is null referencing is to have the built project you're working on. I will swap out Rewired_Core.dll with my own builds and find out exactly what value throwing. There isn't anything more I can do from the outside.
     
  37. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    I was looking at the ReInput.smOfSwMzYaMQxoaqDWRqCqteguQ method.

    Even Obfuscated its 170 lines, it's like nothing.

    But i can understand the code even tho it's obfuscated, it's just a matter of getting used to what you are looking at.

    I was able to determine what is apparently causing this issue.

    Reading your code, i saw that you look for the Platform specific Plugin DLLs that you made to access the Native XInput and DirectInput via SharpDX.

    When you do this you check which assemblies are loaded into the current Domain.

    Turns out that Rewired_Window.dll is not being loaded up by Unity even tho it's referenced, it's as if it did not even exist.
    I attempted to manually load the Assembly, and i confirmed that it was loaded, but even then i still get t he Null Reference.

    Now i am getting closer and closer.

    In my Demo project in Unity, when i delete the Rewired_Window.dll from the project, i get the same Null Reference error i get in my compiled game.

    So i am assuming it is something related to how Unity is handling this reference, for some reason there's something happening when Unity is Build with the Rewired_Window.dll in it, and when it's not.

    I am trying to figure that out now.

    I am also making other attempts, i will get to the bottom of this one way or another.

    It's just how i am.
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    My code isn't doing any checking for any assemblies. That code you're reading is never executed. It is left over from Unity 4.x/5.x before they had the ability to include assemblies by build target. Rewired simply calls functions exposed by the assemblies Unity links through an interface. If Unity isn't linking or loading Rewired_Windows.dll, that's a problem. Did you include Rewired_DirectInput.dll in your Plugins folder in your build?
     
    Last edited: Apr 26, 2021
  39. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Yes the DirectInput dll is in the Plugins folder.

    I am not talking about the
    Code (CSharp):
    1. UnityTools.unityVersion < UnityTools.UnityVersion.UNITY_5_0
    I am talking about:
    Code (CSharp):
    1. return ZNlaysBsXanOQZsWSkzTFTqBINrP.smOfSwMzYaMQxoaqDWRqCqteguQ(GetPlatformSpecificAssemblyName(), list, configVars);
    But i got past that, it is loading the Rewired_Wndows alright.

    I am still unsure what difference it makes to have the DLLs when the game is Built, and not having when its Built and adding them later, but i will have to find out.

    About sending you the project, i could send you the empty test project, but it's clear now that i am not able to explain correctly, how my workflow is.

    Perhaps if we could make a video call, i could show it to you, it would be much easier.
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    I know. The functions inside:

    Code (CSharp):
    1. return ZNlaysBsXanOQZsWSkzTFTqBINrP.smOfSwMzYaMQxoaqDWRqCqteguQ(GetPlatformSpecificAssemblyName(), list, configVars);
    Run for both Unity 4/5x and all the rest. Unty 2017+ exits out before anything is ever done with Assemblies. That's not how they're loaded anymore so none of that is relevant.

    Sorry, no. I don't have time to be doing video support calls. This has taken many hours of my time up already. If you want further help with this, send me the test project.
     
  41. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Yeah it is taking many hours of my time too, way more than i anticipated, but i need this to work so, here i am.

    Don't worry i won't bother you anymore.
     
  42. little_box

    little_box

    Joined:
    Aug 22, 2017
    Posts:
    27
    Hi, guavamam.
    How do I control the sensitivity of axis? I used threshold and duraton in Update, but it was not satisfactory.
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Sensitivity of Actions queried as an Axis:
    https://guavaman.com/projects/rewired/docs/InputBehaviors.html

    Joystick Axis Sensitivity

    This allows you to change joystick axis sensitivity for a particular Action or Actions. This can be used to change look sensitivity for example across all joysticks that are assigned to a player. See Rewired Editor - Input Behaviors for more information.

    Sensitivity of the controller axis itself:
    https://guavaman.com/projects/rewired/docs/HowTos.html#calibrating-controller-axes
     
  44. jtbentley

    jtbentley

    Joined:
    Jun 30, 2009
    Posts:
    1,397
    Hey Guavaman!

    I'm working with a platform that may or may not have a keyboard attached, and the ReInput.controllers.Keyboard appears to never be null, and the isConnected bool property never seems to toggle to false.

    Is there a method for detecting the presence of a keyboard?
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    No. This information is not tracked by Rewired. Every platform except Windows implements keyboard support as direct pass through from UnityEngine.Input.

    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms
     
  46. diccon

    diccon

    Joined:
    Sep 13, 2013
    Posts:
    21
    Hello,
    I've been enjoying working with Rewire, and have successfully created two keyboard maps in my game, one for gameplay and the other for UI, so when I wish to pause the game and display the pause menu I disable the gameplay map and enable the UI map (as well as setting time step to zero etc). I have set up my gameplay map so that my vehicle has an engine input value on a key press using an InputBehaviour that uses digital axis simulation and gravity of 0. The idea is that you can accelerate to the desired input and then take your hand off the key and it will keep the same value. However when I pause the game and restart it this value resets to zero, so my desired engine input is lost and I have to accelerate again which is annoying and feels incorrect to the player. I am able to record the last value of the input prior to the gameplay map being disabled, is there any way to reset the digital axis value to this recorded value when the gameplay map is restarted?
    Thanks for your help.
     
  47. sas67uss

    sas67uss

    Joined:
    Feb 8, 2020
    Posts:
    81
    Hi
    Is it possible to create position_customizable touch controls that the player can drag and move touch controls on across the touch_screen and save this new positions as controls settings ?
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Don't encode game play logic into the input system. The only reason the Digital Axis settings exist is because Unity has the equivalent settings in their legacy input manager and Rewired was designed to exactly mimic their default settings out of the box.

    Rewired always uses its own unscaled, internal timer for anything dependent on time. Input is never affected by Time.timeScale on purpose. Input should never be affected by time scaling.

    Your engine value should be a variable in your script and not obtained directly from input. Increase and decrease your engine value over time in your script based on the current input Action value.

    This is relevant:
    https://guavaman.com/projects/rewired/docs/Actions.html

    Rewired’s Purpose and Responsibilities

    It is common for Rewired's Action system to be used in an unintended manner as an integral part of or in place of a separate game state management system. This is not what Rewired was designed for and not how it is intended to be used.

    • Rewired’s sole purpose is to read user input.
    • All “Actions” in Rewired are actually “Input Actions” and should not be used for any other purpose than to get information about the user’s intent. They should not be confused with or used as game states or actions.
    • The Action “Jump” does not designate “Player is jumping,” but rather “The user wants to jump.”
    • The game should implement permission and state management systems that evaluate user input and then change states. After that point, what happens is outside the responsibility of the input system.
     
    Last edited: Apr 29, 2021
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    That is definitely not a built-in feature. The touch controls that come with Rewired are Unity UI elements. You can move them around the canvas as you see fit. But you're going to have to do the work to prevent them from capturing input while you allow the user to move them around, then re-enable it when they should function as controls. There may be some data cached on Awake by the controls that will cause problems trying to move them after they've already been initialized. For example, the default position is recorded on awake. This would have to be re-set when moved by calling SetDefaultPosition on the control.
     
  50. sas67uss

    sas67uss

    Joined:
    Feb 8, 2020
    Posts:
    81
    You meant is creating a fake controls UI in setting Scene and letting user set position of each them and save this data as for example Jason and fetching them in main Scenes and reinitializing controls position on Awake ?
    does rewired support drag and drop objects with touches on ?