Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by unity_DKqnJkGo8MOKYQ · Jan 22, 2019 at 05:13 AM · inputmanagerproject settingsplatform-support

Platform Dependent Project Settings.

In ProjectSettings>Input, I can conveniently set a mapping from joystick axes to functions in my game.

Unfortunately, axis numbers differ on platforms. If we take, e.g. the XBox 360 controller, it will have the L/R triggers on axes 9+10 on Windows. Yet, it is 3+6 on Linux, and 5+6 on Mac.

The documentation recommends platform specific mappings. But how can I achieve this?

Is there a way to have multiple versions of ProjectSettings/InputManager.asset and have unity pick the correct one, based on which platform it is running (both in-editor and stand alone?)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by guavaman · Jan 22, 2019 at 08:01 PM

You can't do that, at least not officially. You could swap out the InputManager.asset file every time you make a build, but it wouldn't help if you want to support more than one gamepad type.

The normal way of handling cross-platform input is by either creating your own input manager or buying an input manager system from the Asset Store. Most input managers that wrap UnityEngine.Input will create an exhaustive list of Axes in the input manager, one for each possible axis on every joystick id. You poll the Axes in the input manager for all connected joysticks to get the axis values. For buttons, you poll Input.GetKey using KeyCodes for all buttons on all possible joysticks. Then, to make things cross-platform, you need a system that maps from a pre-defined controller definition that you've created (for each supported platform) to a standardized layout. Then your code can just reference the standardized layout. It can get very involved and be very time consuming to create an input manager like this, especially if you want to support more than a few controllers. There are some good input managers on the Asset Store that can do this including my own Rewired, which does this and a whole lot more.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TreyH · Jan 22, 2019 at 08:18 PM 1
Share

Adding to this, Unity's got their new Input system up as a Preview package, which should help relieve some of the cross-platform headaches.


Until then (assu$$anonymous$$g you don't want to build with preview packages), you will probably want to define those cross-platform values yourself. This was an example input manager I made for a project awhile ago which tackles the same problem:

https://pastebin.com/AxdkVwTr

The part you probably want is towards the bottom, a static class called ControlCodes that defines xbox input across platforms.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

99 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Platform falling script 1 Answer

mac platform 1 Answer

How do i reset settings? 2 Answers

Adding Shift as a Button 1 Answer

Joystick Input - "3rd Axis" etc, not sure what works/doesn't 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges