jInput Mapping

detailed explanation

Thank you for liking  jInput Mapping!

This page is explanation the introduction method and how to use of jInput Mapping. It is easily add input setting system(It is also called Input Mapping, Key Config, Key Assign) in Unity game you make. In addition, it is explaned to further customize.

If you are not get jInput Mapping, please try first it in the demo page.

It is possible to use GamePad, Joystick, keyboard, mouse, any input device, and possible to get input signal by GetKey&Button, KeyUp, KeyDown, GetAxis&Raw, any input get script.

For example, if a player set the analog stick to the script 'GetKeyUp', it is possible to get when the stick returns to the neutral zone(stick up). It get all kind response by just same source without the differences such as Axis / Key / Button. It can take several input device in the same time. There is no need to worry about the operating environment of players, and players also use any device freely to enjoy the game. jInput will remove obstacles between your Game and player input device!

Set up

It is explained the procedure of import jInput Mapping in this chapter.

  1. Check the Demo
  2. Add to your project
  3. Note of new version import
  4. Avoidance of conflicting settings

Check the Demo

When the import process of asset has been completed, it is displayed the message that "[jInput] Initial setting has been completed." in the Console window. There are all jInput files into the jInputMapping folder in the ProjectWindow on Unity.
In terms of location on the OS, in the project folder/Assets/jInputMapping folder.

There are two demo scenes in that folder, 'InputMappingDemo' and 'InputMappingUGUIDemo'. UI of InputMappingDemo is all made of 3D object, and UI of InputMappingUGUIDemo is all made of UnityGUI. When the import was complete, please try playing either Demo scene once and confirm it works properly.

[supplementary] In the initial setting, your previous InputManager.asset is renamed to InputManager(original).asset so as to kept separately. If a file named InputManager(original).asset already exists (such as re-importof jInput), the previous one is kept and not be overwritten.

Add in your project

It is easy to add jInput in your project if Demo already worked. Select and copy 'jInputMappingSet' from the HierarchyWindow of the demo scene. And open your project and paste that object into the scene.

jInputMappingSet have the objects such as UI, that is to constitute the scene of input mapping. This is put in the scene of setting input such as the game options scene.

[supplementary] If you have already used script name the same as this asset, it does not work as is. This is specifications of Unity. In this case, it is solved by use the namespace and so on.

[supplementary2] In a rare possibility, if it is happen you have already made the GameObject with the same name 'jInputMappingSet' or 'jInputMappingManager', jInput does not work correctly. And do not change the hierarchical structure in jInputMappingSet, and do not put extraneous thing where into GameOobject like a folder structure in this.

[supplementary3] In 3D object version, it may come out a strange display jInputMappingSet be caught by the camera that you have put in the scene. Because jInput UI has own camera, so enter the screen from two cameras. In this case, jInputMappingSet put on the position of not used in the world, or use CullingMask setting of the camera.

Note of new version import

After import new version of this asset, open the scene there is jInputMappingSet GameObject in your game at first. The changes of the update will be adapted to function by that. If you do not do that, jInput might not work normally because the part of updated and the data until that time differ. Do not forget that when the update.
Play the scene once incidentally, it would be better to confirm that the error does not appear in the new version.

In addition, Prefab, texture and so on are overwritten by re-imported for the update, so take care that if you make any alterations of those resources for the design. Those resources are gathered in jInputMapping/Components folder, so it keep separately in different location from imported location that the things of you make any alterations.

Avoidance of conflicting settings

jInput execute initial set to add for settings until import its own so as to retaining your settings as much as possible. So it rarely happen an error to conflict for other assets or your settings. But conversely, other asset of poor behaved is imported later and settings required for jInput is had been erased by overwriting, jInput is unable to worked correctly. In such cases, you may avoid to conflict by this asset import at last to retain other settings.
Similarly, the player of your game would change the Input setting of Unity noemally in the standalone game to be built for the PC, there is a possibility that it will not work correctly by set to differ.

Use

It is explained that the basic knowledge and setting in order to use jInput in your game. Here, to explain the procedure step-by-step to avoid getting lost for anybody who still just started to use Unity, and what you must follow the procedure is simple.

  1. How to write the script
  2. Increase or decrease the mapping elements
  3. Change the heading of the input mapping item
  4. Setting of the number of players
  5. Setting of the default keys
  6. Plural mapping of the same key
  7. The keys do not use the mapping
  8. Setting of the exclude device
  9. Key operations in UI
  10. Whether to use the definited behavior of Esc key
  11. The way of opening and closing the mapping window
  12. The DeadZone,Gravity,Sensitivity of Axis
  13. An error still occurs

How to write script

The script to be written to use jInput in the game, it is almost same as the general source code of Unity. You will be almost used as it is in the knowledge if there is experience with using the general Input of Unity. Anyway here is example of the script for single player game (Player1).

Only replace the source code from Input.Get... to jInput.Get... . In addition, elements of input mapping set by the player are stored in the Mapper.InputArray[].

var v = jInput.GetAxis(Mapper.InputArray[0]);

It get the input that be set to 0th array. As an example to be reflected the source code for operation of such as character move, it would be understanded easyly just by looking at the DemoCube.cs that be moved the DemoCube GameObject in Demo.

In the general input state of Unity, the bool of GetKey, GetKeyUp, GetKeyDown are not able to get directly the operation of such as analog stick, but jInput is possible. For example, if a player set the analog stick to the script 'GetKeyUp', it is possible to get just as it is when the stick returns to the neutral zone(stick up). It get all kind response by just same source without the differences such as Axis / Key / Button. So your scripting is minimal.

The general axis input state of Unity is behavior in the opposite direction e.g. get -1 to 1 using a pair of upper and lower by analog stick. jInput separate them, the upper 0 to 1 from neutral and the lower 0 to 1 from neutral. This have made easy to set the completely different action to opposite direction of Axis. If you want to make a process must be get a usual Axis state between -1 to 1, to write same as the DemoCube.cs for move DemoCube.

var vPositive = jInput.GetAxis(Mapper.InputArray[0]); //up
                            var vNegative = jInput.GetAxis(Mapper.InputArray[1]); //down
                            var v =  vPositive - vNegative; //v is -1 to 1

Increase or decrease the mapping elements

First, decide the number of input mapping items in your game. In the Demo, there are total number of seven input mapping items that consisting four direction and three movement in 3D object version, and there are total number of ten input mapping items that consisting four direction and three movement and three dummy items(they are making up the numbers and column in a vertically for scroll operation check) in UnityGUI version. Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. There is 'Size' field of Menu Item Headings in jInputSettings script, to assign the number of input mapping items in there. Items can be made up total 31(from Element 0 to 30).

And then, open directory jInputMappingSet/MainWindow/InMapperMenuItems in HierarchyWindow. In there, objects has been created with a serial number, these are same number as the number that has been previously assign.

It is corresponding, MapperMenuItem00 is Mapper.InputArray[0], MapperMenuItem01 is Mapper.InputArray[1]... like this.

For 3D object version

To change the transform.position.y of each MapperMenuItemXX, and to place in numerical order from the top position on the screen. It is described later about design such as each item positioned at regular intervals, so those are placed roughly for the time being at first. Be careful, if you change transform.position.z of item and the depth relationships with other parts is changed, problems happen such as can not be clicked it or can not appear on the screen it. If does not fit on the screen, adjust size and transform of jInputMappingSet/jInputCamera in HierarchyWindow.

For UnityGUI version

When increase or decrease the input mapping items, it is create the connection movement of up, down, left and right in UI(Navigation of Button component) automatically. This is useful because there is no need to set it when you use jInput almost as is default arrangement of UI. If you made some connection movement of up, down, left, and right in your own placement of the UI, it should be noted that connection to return in accordance with default when increase or decrease the input mapping items later.

In addition, UnityGUI version has a scroll bar. Select the jInputMappingSet/MainWindow in the Hierarchy window, and look at the Inspector window. It is set the scroll bar at the part of the UGUIMeniVerticalScroll script in there.

When it is not checked the Use VerticalScroll, it is in the state that not use the scroll bar.
ScrollInto Ratio is speend value that scroll catches up to the cursor position in the up and down movement with the key, and ScrollInto Inertia is is the inertial force value at that time. If you are unsure these, it would be easy to understand that extremely changed these value and and try to scroll to the upper end and lower end in the movement of the key at Play the scene once.

It is not possible to Play the scene yet if you added more input mapping items, because it is not performed concomitant other settings. Move forward settings of jInput.

If you do not make a number of this equal or greater than the number of elements of Mapper.InputArray[] you are using in scripts, it occurs an error. For example, using Mapper.InputArray[0]...Mapper.InputArray[6] in DemoCube.cs in Demo, it is an error to reduce less than seven the number of input mapping items if DemoCube.cs as it is. Such errors will appear in that case.

Change the heading of the input mapping item

There are headings that UpMove,DownMove,...Particle to the left of each input mapping item in jInput mapping window in Demo. To match this with the operation of your game.

Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. Each Element of 'Menu Item Headings' in jInputSettings script, to fill in the suitable heading words.

Setting of the number of players

It is necessary to set the maximum number of players in the same place. It do not mean through the transmission such as the Internet. For example, if friends meet in a room and to connect some GamePads to one game machine, the maximum number to be able to connected. Each player who connect to the same program can set each input mapping by this.

Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. It is selected maximum number of Players from 1 to 4 by 'Max Players in Same Place' in jInputSettings script. 4Players is the upper limit of the specification of Unity.

If you select 2-4Players, the player select window appears when play the scene of the mapping window.

How to write the script of Player2-4, it is stored in the following each array.
Mapper.InputArray2p[]
Mapper.InputArray3p[]
Mapper.InputArray4p[]
Other parts are same as the description of single player(Player1).

var jump = jInput.GetKeyDown(Mapper.InputArray2p[5]);

It get the input that be set to 6th array of Player2.

[supplementary] When it is set Player2-4, it is not able to set input of GamePad other than the GamePad that detect input for the first time on the mapping window of each player. This prevent that set the input of other players during the player set input mapping. Specifically, if Alex and Bob meet and playing the game, Alex's GamePad is pushed the button but it is not set when Bob is setting input mapping of Player2.
If Alex want to take Player2 after that, go back to the player select window once and Alex select Player2, start input mapping of Alex and Bob's GamePad is not set this time.
Input from keyboard, mouse, and so on, which can be set freely even when any player is setting input mapping.

When set the input mapping, if the input mapping of the current setting player and the input mapping of another player are interfering (Other GamePad is mixed in input mapping, or the same key as the other players is being set), caution mark appear in the upper left of the item.

It is intended to modify the input mapping for the player, but dare to keep that and it is possible to irregular use such as move in unison the two characters in one key or two players share the operation of one character.

Setting of the default keys

Must set default keys that has set from the start of your game, these are used when the player has not set input mapping yet. Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. Default keys of Demo is set at 'Default Input Mapping' in jInputSettings script this time.

To assign the name of default keys in your game in each field. Or select from the drop-down list in the right, it is assigned automatically. The name of the key setting is in accordance with the following rules.

If the key or button has KeyCode, to assign the KeyCode just as it is
an example :  'A'  'Space'  'Mouse0'  'Joystick1Button0'

Axis of such as Joystick, to assign the following regular name
'Joystick1Axis1' ... 'Joystick1Axis20' ... 'Joystick4Axis20' and
put at the end '+'or'-'
an example :  Joystick1Axis1+

Mouse wheel is 'MouseWheel' and put at the end '+'or'-'
an example :  MouseWheel-

Beware of which is required to trailing '+'or'-'. You do not need to worry about the difference of Upper/Lowercase because it is corrected automatically. You will see immediately if the assigned key name is wrong, because Drop-down list on the right becomes blank state. And there are each numbers just after 'Joystick' is 1-4, just after 'Button' is 0-19, just after 'Axis' is 1-20.(It seems a little unintelligible but it is conform to the notation of Unity standard.)

There is a KeyCode list here. However, do not use the description that JoystickButtonXX, it needs to be use the description that 'Joystick1ButtonXX'...'Joystick4ButtonXX'. The description which JoystickButtonXX get any responses by the same button of any GamePad which is connected same time, so it is cause confusion in such as multiplayer game. So jInput exclude it from the mapping. Need to use the description which Joystick1ButtonXX...Joystick4ButtonXX that to be given GamePad number.

That is required '+'or'-' at the end of the name, those are opposite direction and work in the same name by general Input of Unity, but jInput is distinguished these opposite direction. For example, the left and right direction are same state in general Input of Unity and gotten value between -1 to 1. But in jInput, the right direction that name 'Joystick1Axis1+' is gotten value between 0-1 and the left direction that name 'Joystick1Axis1-' is gotten value between 0-1, those are separated. It is enabled to set quite different action in opposite direction easily.

If you are hard to find the the name of the desired key in the drop-down list, in turn the key name is focused with the initials each time you press the first letter on the keyboard when open the drop-down list.

Instead it, you can also set the default keys actually pressing the keys in the same way that a game user is mapping. Press the 'DefaultKeySetMode' button at the bottom of the player item you want to set, marked with [ON] to the button, and scene is Played with the default key set mode.

Set to the default key actually press the key in the scene. It attaches further * mark in the DefaultKeySetMode button when something to set the default key.

The default key that you change will be reflected when you press this button again after finished setting. If you want to go back to the default keys before this setting, stop the Play scene by Press the normal Play button at the top of the Unity instead of the DefaultKeySetMode button. In this case, remain in the previous default keys and not apply thea you set in the scene.

When you are finished setting up so far, try to Play the scene once. Default keys are checked at the scene starts, and it returns an error if wrong the default key name. It is an similar error if there is a blank in the default key name to Player1.

If the error happen, the scene is stopped and folding of the relevant part is opened in the InspectorWindow. And error log suggest the part of incorrect settings appear underneath of the column of Default Input Mapping.

After correct, to Play the scene again and check the error become not apear. When Play the scene successfully once, normal default keys are saved and jInput will work correctly.
If it was able to Played the scene successfully without errors, you should save the scene once. The values of the InspectorWindow that you have entered so far are also saved at this time.

[Supplement] In the case of the head of key name is Joystick..., the number part of key name is different variously by number and kind of connected input devices. For that reason, the player necessarily can not operate at the same key name of your environment. This is the specification of Unity and operating system. It will not happen in a console game that the input is unified on each platform. But there are many environment on PC and so on, so it is possibility that there is not default keys of you have assigned in the GamePad player have, or be detected opposite value of up and down in the other GamePad. KeyCode of a keyboard and mouse is the common input name in anything environment, so may as well assign wide commonality KeyCode at default key in PC game, and put the mapping of GamePad in the hands of each player. If absolutely you set the GamePad to default keys, it is safer that using 'Joystick1...' for Player1, 'Joystick2...' for Player2 and do on.

[Supplement2] In the InspectorWindow, default keys are able to sorted by drag operation. If you want to change the placement of default keys after you have set, you will be able to sort without re-setting one by one.

[Supplement3] If the number of save data value is different the actual number of input mapping items such as you change it during fabrication, jInput automatically create a new save data to set of default keys when Play the scene. This is also in order to initialize the save data if such a thing should happen the save data differ by a something factor during play the game.

[Supplement4] If jInput can not load the save data successfully cause by save data value is funny or save data has been corrupted, it is deleted the save data file. Then, to be stopped the Play if it happen on UnityEditor, or re-start the mapping window if there is it in the scene on other platforms. And input mapping is returned to default keys. In short, jInput perform reset itself.

Therefore, if the default key name is wrong in game that have been built, re-created the save data becomes an error again and repeat this, do not operate normally. So you must make sure the default key name is proper. Do not forget to Play the scene and to confirm it is not happen an error.
It will be executed LoadfailureDeal() method in Mapper.cs when happen the error of could not be performed load data. To utilize this method if you want to reflect something such as display to care notice when the error.

Plural mapping of the same key

jInput can be mapped the same key in separate items in default work. It is possible that a game player can be mapped like to press simultaneous freely. But it has case the strange behavior if a game player is not intend that mapping, so it is suggested by the color of mapping key name. And it can be possible to change that mapping a same key in some separate item.

For 3D object version

Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. At 'Preclude Same Mapping' in jInputSettings script, it is make that a game user cannot set a same key in a separate item when this is checked.

If a game user try to mapping a same key in a different item, each assigned key change places and the key is always set mapping to only one item.(This is a common behavior in general mapping system)
If it is checked on this, note that it is an error if a same key is set in some separate item in default key mapping.

Without taking the above check, in the case to enable the mapping a same key, it is changed the color of suggestive it. But unlike UnityGUI version there is no item to be set this at once, so no problem with read to next for now. It is explained more detail later in the chapter of Design.

For UnityGUI version

Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. At 'Deal with Same Key' in jInputSettings script, these are changed.

At 'Preclude Same Mapping', it is make that a game user cannot set a same key in a separate item when this is checked.

If a game user try to mapping a same key in a different item, each assigned key change places and the key is always set mapping to only one item.(This is a common behavior in general mapping system)
If it is checked on this, note that it is an error if a same key is set in some separate item in default key mapping.

Without taking the above check, in the case to enable the mapping a same key, it is changed the color of suggestive it. It is set at 'Same KeyName Color', it marked with that color to the edge of the duplicate key name.

The keys do not use the mapping

It is able to set the keys that a game player can not be used in the Input mapping. For example, when you set a fixed special work to Return key, if a game player is mapping other operation for that key, Return key has two behavior and it works wrong. In such case, it should not be used to mapping to the Return key.

Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. It is assighed the number and the key setting names that can not be used mapping at 'Unusable Mapping' in jInputSettings script. About the key setting names, it is same as the setting of the default keys that described above.

Setting of the exclude device

It can be disabled mapping the keyboard or GamePad in each player. Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. At 'Exclude Device' in jInputSettings script, it can be selected to exclude a device in each player.

For example, it can exclude the GamePad in the case of you want to play your game only in the keyboard. In this case, of course keep in removing the key of the GamePad from the default input mapping.
Or 1P is set GamePad only and 2P is set keyboard only in the game for one person, it can be had each mapping of the GamePad and keyboard separately. In this case you need to modify slightly the text such as Player1 in the scene.

Mouse can not always be excluded. Because if a game player into inoperable, to be able to come back to the mapping scene by mouse or touch operation.

Key operations in UI

It need to transmit the key items that you made to the UI system. It says in UnityGUI that normally unity system, it need to be set the behavior of the key such as Vertical Axis and Cancel Button in Standalone Input Module component, it is same that.
Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. At 'UI Operation Settings' in jInputSettings script, it is set the key item to operations in each drop down list.

The key items are set that in here, those work as designated bihavior in jInput and UnityGUI in your game. It is possible to set some items at a bihavior, for example you can make some items of the Cancel bihavior.

About UpMove/DownMove/RightMove/LeftMove, these are Up, down, left and right movement in the mapping window and UnityGUI.
UGUISubmit is Submit behavior in UnityGUI, UGUICancel is Cancel behavior in UnityGUI.

'ExcludeDecisionFunc' is excluded the key from the decision behavior on the mapping window. For example about decision behavior, if you press any of key on the keyboard in the somewhere item on the mapping window, it is reaction and become the to wait mapping condition though the key is not set input mapping yet. This is a decision behavior. Almost all keys work as a decision behavior on the mapping window because simplicity and certainty of operation. (It is like almost all keys are work as Submit operate on the mapping window only.) But the operation will become strange if all keys working decision such as direction key or cancel key works as a decision behavior same time. For example, if the key works not only direction but also decision behavior, it would move and decide at the same time and the cursor is not able to moved normally by that direction key. Because of this, it requires that the key of the specific operation can not work as a decision behavior on the mapping window.
Items assigned to each direction and UGUICancel are set to ExcludeDecisionFunc automatically. Because these are become to strange behavior for the above reason if these work as decision behavior. Select more item according to the key operation in your game if you do not want to work as decision behavior in jInput.

Moreover, If you use UnityGUI in your game, it must be set to StandaloneInputModule of Unity standard with that. Because if two instruction to UnityGUI from jInput that set just above and from the Input system that standard of Unity work at the same time, operations on UnityGUI is worked doubly and it works wrong.

Look at the Inspector window of StandaloneInputModule that using in your game. Those fields are set as follows.
- Horizontal Axis: jInputHorizontal
- Vertical Axis: jInputVertical
- Submit Button: jInputSubmit
- Cancel Button: jInputCancel
With these, it can be also operated UnityGUI in your game using jInput.

Whether to use the definited behavior of Esc key

Escape key is can not be mapped permanently. However Esc key have behavior that opening and closing the mapping window or cancel on the mapping window. For example, it has been pressed the Esc key when waiting for the input of something mapping key on the mapping window, canceled that state and return the normal state. You can choose the behavior of Esc key whether it also works on the mapping window of your game or it does not function at all in jInput.

Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. When it is checked that 'Use Esc Definited Behavior' in jInputSettings script, Esc key is used as the cancel behavior determinately on the mapping window. And when it is not checked, it does not have any work on jInput.

It seems as is often the case that Esc key is already used to end the game and so on. jInput is not possible to use for mapping the Esc key, so never conflict with mapping of the player of your game. And it does not conflict with the operation of the mapping window if it is not checked.

The way of opening and closing the mapping window

In the demo, Escape key work the behavior of On/Off the mapping window. In actual case, it is often used the another way of call the mapping window such as opening from the game menu. Decide the way of how to call the mapping window in your game, and make into mapping from your game scene. The way of opening and closing of the mapping window would have several methods that depending on how the construction of your game.

1).jInputMappingSet is placed on the same scene that be
   placed on others, and it is switched SetActive(true/false).
2).jInputMappingSet is placed on the scene of a single individual,
   and change the whole that scene by SceneManager.LoadScene().
3).jInputMappingSet is placed on the scene of a single individual,
   and add the scene to current scene by SceneManager.LoadScene()
   with LoadSceneMode.Additive.

Demo use the way of 1) to opening and closing of the mapping window. It is easist to treatment the way of 1), so you would be use this if you do not have a particular thinking. Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. Make the settings for opening and closing the mapping window at 'jInput Open/Close Settings' in jInputSettings script.

The way of 1)

When selected 'SetActive to Open', it means to open and close the window by SetActive(true/false).

First, put jInputMappingSet gameObject at the scene of input mapping. key configuration to scene. In this case, jInputMappingSet ready for operation and become SetActive(false) automatically at the scene start. So you do not set SetActive(false) manually.

If you want to open the mapping window, it is processed properly by executing the follow method in script.

Mapper.MappingWindowOpen();

To close the mapping window, it is pressed the Close(Exit) button of UI in the scene.

When closing the window, it is executed at the same time that the method of assign in ClosingEvent in the Inspector window, so it can be used such as playing a sound of close the window.

The way of 2)

You want to use the way of 2), 'SetActive to Open' is not selected. In case of that the way of 2), the mapping window does not need to become SetActive(true/false) when opening and closimg the window because this way is used the method that changing the whole scene.
First, create a new scene and put jInputMappingSet gameObject there. It means that opening the mapping window by change from your game scene to this scene, and it means that closing the window by change from this scene to other scene. The mapping window appear whole scene and disappear whole scene.

If you want to open the mapping window, move from an existing scene to the scene that put on the window by SceneManager.LoadScene().

If you want to close the mapping window, assign the method to move to another scene at ClosingEvent in the Inspector window. When Close(Exit) button of UI pressed in the scene, ClosingEvent is executed after appropriate processing and it will be moved to another scene.

The way of 3)

You want to use the way of 3), 'SetActive to Open' is not selected. In case of that the way of 3), the mapping window does not need to become SetActive(true/false) too when opening and closimg the window.
First, create a new scene and put jInputMappingSet gameObject there. It means that opening the mapping window by add that scene to your game scene, and it means that closing the window by SceneManager.UnloadScene() whole the scene that put mapping window. It can be continued the existing scene just to unload only the addative scene.

If you want to open the mapping window, add the scene that only put the window to the existing scene by SceneManager.LoadScene() with LoadSceneMode.Additive.

If you want to close the mapping window, assign the method to SceneManager.UnloadScene() at ClosingEvent in the Inspector window. When Close(Exit) button of UI pressed in the scene, ClosingEvent is executed after appropriate processing and it will be unload the mapping window.

As all of the way, you can also close the mapping window as if pressed Close(Exit) button by the following script.

Mapper.MappingWindowClose();

However if it is executed in bad timing for closing the window, it will work as like cancel behavior. For example, esecuted it when performed the confirm window, closing only the confirm window and the whole mapping window is not closed.

The DeadZone,Gravity,Sensitivity of Axis

Axis input can be set that DeadZone, Gravity, and Sensitivity. Click jInputMappingSet in HierarchyWindow, and look at InspectorWindow. Set the values for each slider at 'Axes Advance Settings' in jInputSettings.cs.

The values in here is set at once to all Axes. Usually, if you change the values in InspectorWindow when Play the scene, Unity return to the previous value when Play stop. But the values in here are keeped even after stop Playing. It is easy adjustment of the values while Play the scene, so it will be good to be adjusted the suitable values while moving actually player character of your game.

An error still occurs

If you had intended to follow the explanation but an error still occurs, try to play the scene again after remove the save data of input mapping. In particular, if you make your own changes to the script, there is a possibility that to be contradictory to the current program and previous save data. In initial setting, there is the save data on UnityEditor in the location of the project folder/SaveData folder.

Design

It is explained to design the mapping window of jInput to match the view of your game.

  1. How to change the design
  2. Procedures of applying design
  3. Change the size and position
  4. Design of InMapperMenuItems
  5. Design of InMapperOperateItems
  6. Design of ConfirmWindow & ExitWindow
  7. Design of PlayerNumWindow
  8. Design of other things

How to change the design

Most parts are able to changed the design in InspectorWindow. In addition to Unity standard components, design items are added in the script. The items for design depend on the kind of the part.

If you want to design all objects of the same type at once, for example, want to design all MapperMenuItemXX that input mapping fields at once, select multiple those objects. If these are same type, you can design all of select items at once.

Or apply the changes to the prefab and make those items into same state as the prefab, you can be same design simultaneously all of items that dependent on the prefab. Each prefab is located in the jInputMapping/Components/Prefab in the Project window and these are divided into 3D object version and UnityGUI version.

Procedures of applying design

The parts that can be make the design changes from the InspectorWindow, those are made as much as possible that applied the changes and confirmed the actual appearance without playing the scene. Conversely, the changed value when the scene Playing is returned to the previous state, it is specifications of Unity.

Change the size and position

For 3D object version

If you want to change the position and size of each parts, you can change in the same way as a general objects for operations on a SceneWindow or Transform item. But transform.z should not thoughtless move because it does not appear on the screen or not be able to clicked. For the same reason, be careful transform.rotation.x and transform.rotation.y would arise depth to the parts.

Each parts dare not do auto align because to be able to adjusted some extent free position, but input setting items (flock of MapperMenuItemXX in jInputMappingSet/MainWindow/InMapperMenuItems) are able to line up at regular intervals. Click jInputMappingSet/MainWindow/InMapperMenuItems in HierarchyWindow, and look at InspectorWindow.

To enter the value of Interval and press Align button in here, all setting items are aligned at regular intervals in the vertical. Reference position is MapperMenuItem00.

If each setting item have aligned, horizontal alignment X-coordinates are identical, so it is used the transform component of Unity standard. To select some setting items(MapperMenuItemXX) and entering in transform.position.x.

Headings in the side of it, these are adjusted relative position at once.

Click jInputMappingSet/MainWindow/InMapperMenuItems in HierarchyWindow, and look at InspectorWindow. And change coordinates(x,y) of 'Heading Relative Posi'. These coordinates are relative to the belong setting item.

[Supplement] The behavior of UI may disagree with the intuitive operation by changes extremely such as make two columns the input setting items. For example if the input setting items have two columns, would be better right and left key behavior that move the first column / the second column / column of save buttons. Furthermore, be changed the position of the save button at left of sereen, it become a need to fix that corresponds to it.
If you want to change significantly the placement of UI, you should use the UnityGUI version of jInput and control of UI by UnityGUI that Unity standard system. In 3D object version of jInput, it is done that all control of UI by script of jInput, so you need to read and rewrite the script in order to make that change.

For UnityGUI version

Position and size of each part are controlled by components of UnityGUI. Therefore, you will be able to change the position and size on the knowledge of the standard UnityGUI system.
However about the Selection GameObject, transform.position.x is controlled from the script by UGUISelectionController.cs in order to point of the selected Button.

Design of InMapperMenuItems

InMapperMenuItems GameObject compose input mapping fields and those headings. There is jInputMappingSet/MainWindow/InMapperMenuItems in HierarchyWindow.

For 3D object version

Click any MapperMenuItemXX stored in InMapperMenuItems GameObject in HierarchyWindow, and look at InspectorWindow.

The font design is able to changed in there. And it is able to set the color of the input mapping field and the font color. As mentioned above, the heading texts are set in InputMappingSet GameObject.

For UnityGUI version

Each mapping item(MapperMenuItemXX) are nested inside InMapperMenuItems GameObject and those are aligned by VerticalLayoutGroup component in InMapperMenuItems GameObject. And each MapperMenuItemXX have the heading, the button and the alert mark inside it. Click the object that you want to change the design and look at the Inspector window, it is able to changed almost the design according to the specification of the standard UnityGUI system.

About only heading text(InMapperMenuItems/MapperMenuItemXX/HeadingText), it is weited earlier that must be set in Inspector window of jInputMappingSet gameObject. Even if it is rewritten here, it is taked precedence that the heading set in jInputMappingSet gameObject and return it.

Design of InMapperOperateItems

InMapperOperateItems GameObject compose the buttons of system. There is jInputMappingSet/MainWindow/InMapperOperateItems in HierarchyWindow.

For 3D object version

Click any MapperOperateItemXX stored in InMapperOperateItems GameObject in HierarchyWindow, and look at InspectorWindow.

The button text and the font design are able to changed in there. And it is able to set the color of the input mapping field and the font color.

For UnityGUI version

Each MapperOperateItemXX GameObject in InMapperOperateItems, those are in accordance with the Button object and Image object of the standard UnityGUI system. So those can be designed in accordance with the operation of standard UnityGUI.

Design of ConfirmWindow & ExitWindow

ConfirmWindow and ExitWindow GameObject compose a confirmation dialog of save when the mapping window is closed.

For 3D object version

Click any buttons stored in ConfirmWindow or ExitWindow GameObject in HierarchyWindow, and look at InspectorWindow.

The button text and the font design are able to changed in there. And it is able to set the font color.

For UnityGUI version

The buttons and the window frame in ConfirmWindow and ExitWindow, those are in accordance with the Button object and Image object of the standard UnityGUI system. So those can be designed in accordance with the operation of standard UnityGUI.

Design of PlayerNumWindow

PlayerNumWindow GameObject compose the player selection window.

For 3D object version

Click PlayerNumWindow GameObject in HierarchyWindow, and look at InspectorWindow.

The colors of each player number are able to changed in there. In here, texts are generated from the Prefab because the structure of text here is a little convoluted. If you want to change the font design, design text object in Prefab which is assigned to Num Prefab in the usual way of the Unity.
CloseButton can be designed in a same way as ever.

For UnityGUI version

PlayerMappingNums GameObject(PlayerNumWindow/PlayerMappingNums) have Horizontal Layout Group component, and it is aligned each player selected button(PlayerXMappingNum) that are nested within it.

When changing the players maximum number in the jInputMappingSet GameObject(the value of Max Players in Same Place), each PlayerXMappingNum changed SetActive(true/false) as only show the necessary nunber, and the value of the Spacing of the HorizontalLayoutGroup component that mentioned above is set to the good value. And create some connection movement of up, down, left and right in the GUI(Navigation of Button component) automatically.

Those are useful if PlayerNumWindow is used in the default position of UI, but if you change the players maximum number after changing the placement of PlayerXMappingNum in your original, it is needed to be aware that the position is shifted by this work. You do not need to worry about it if you follow the procedures of this site that to determine the players maximum number at first and next changing the position of UI.

Each PlayerXMappingNum have the structure that two Text objects named "Player" and "Number" inside the Button object. The color set in the Button component of PlayerXMappingNum is applied to Number Text object.

Close button and the window frame in PlayerNumWindow, those are in accordance with the Button object and Image object of the standard UnityGUI system. So those can be designed in accordance with the operation of standard UnityGUI.

Design of other things

Other things are ordinary objects such as not to be changed the color from the script, so these are designed in a way of standard Unity.
In addition, about designing to other ingredient of parts that have been mentioned so far such as changing the texture, those are designed in a way of standard Unity too.

Detail

This is meticulous points to be kept in mind.

  1. Attention to the operation of deny each other
  2. About save data
  3. Avoid the happening to be impossible to operate

Attention to the operation of deny each other

jInput is able to mapping to the different operation at one key, so set easily same meaning the simultaneous push of some button. Therefore there is the point which you must be careful during creating the game. For example, if player sets to the contradictory behavior such as decision operating and cancel operating at same key, then he cannot operate normally and perhaps happen he cannot come back to the key mappimg scene and cannot modify this condition. In this case, it will be a relief for the player of wrong way that you have writed the process of simultaneous input in the script. In jInput UI take a step of this in jInputSettings.cs. You can confirm in Demo it is inputted the up movement only that try to simultaneous input the up and down.

if (jInput.GetKey(Mapper.InputArray[6]) && jInput.GetKey(Mapper.InputArray[7])) { //two operatings in same time
    jInput.GetKey(Mapper.InputArray[7]) = false; //only Mapper.InputArray[6]
}

In addition to this, it is valid that a player can open the mapping window from title scene by even only touch and mouse operation, and come back to fix the settings.

About save data

Save data will be written on an encrypted binary file on standalone platform(include on UnityEditor). It is for not use the registry. And there is a advantage that the player can hold some data easily in PC game. 'SaveData' folder is created in the directory where there is the execution data of game program, and 'InputMapping.dat' file is generated in it.

You can change the dat file name and the file hierarchy of be generated save data and the Rijndael encryption key by modifying the SaveLoadScript.cs.

The save data except on standalone platform using PlayerPrefs, it is follow the way of Unity.

Avoid the happen to be impossible to operate

After the player saved his input mapping data, postulate he change connecting the other GamePad or change to the keyboard operation by reason of such as the previous use GamePad broke. There is a possibility that there may not be the key of the previous settings in current input device, so he can not to operate to open the input mapping scene and he can not retry input mapping. As a specific example, he change GamePad from it had 10 buttons to it have only 4 buttons. If he have set operation to open the options menu of the game to the 10th button, he can not press the 10th button because it is not physically present in current GamePad. It is impossible to open the options menu, so he can not open the scene of input mapping. This will not happen in console game that the input environment is unified on each platform. In addition, there is no problem on mobile terminals if it is able to opened the options menu by the touch operation and so on. This problem can happen on such as a PC that there are many type of input devices and many kind of input environments, furthermore in case of the game can not do the operation of the touch or mouse.

A simple workaround, writing the way of restore to the default input mapping in the explanation and ReadMe. Delete the save data that mentioned in the above topic, input mapping return to the default at start the game next time. You should write that in case of his input environment has changed and can not operate the game, delete the save data and restore to the default input mapping, and to set his input mapping anew. I think it better the default input mapping is set the keys on the keyboard of broad commonality, it will not be happen a player can not operate the game. Of course, it is valid that a player can open the mapping window from title scene by even only touch and mouse operation.

Support

There is about support.

  1. Inquiry or demand
  2. Release new virsion

Inquiry or demand

If you have inquiry or demand, please feel free to write in the support forum.

Release new virsion

When a new version comes out, it will be written on the support forum such as points of modification. Please take a look there occasionally. Or you can see the simple history, check the release notes in the linked page.

Please obtain from the asset store if a new version was out.

© 2014-2016  Myouji