Cross-Platform Input Controller in Unity, part 1: Setting things up.

Esteban Ibarra
4 min readSep 1, 2021

Unity provides us with mobile touch controls via their standard asset pack. It’s not built in, so we’re going to have to open up the Asset Store window and search for “Unity Standard Asset Pack”.

Open up the Asset Store:

Search for “Unity Standard Asset Pack”

Once found, select it and it will show a button to import it, go ahead and do it, it will then pop up with an import menu, press the import button and take a coffee break.

Once everything is imported, go ahead and close the asset store, we won’t be needing it anymore.

If it’s already installed, you may have to go to the menu and install it via: assets/import package/cross platform input

Once installed, there will be a Standard Assets folder in our assets menu, go ahead and open it up, and look for CrossPlatform Input/Prefabs/MobileSingleStick Controller and drag it up into your scene, it will implement a simple control scheme in your canvas.

Now that we have an actual interface, let’s turn off our Huds Joystick image.

And we’ll drag the hud Thumb_Button image into the MobileSingleStickControls MobileJoystick Sprite:

Select ‘preserve aspect ratio’ in the image option and adjust the joystick graphic to your liking:

Using Unity 2019, there seems to be an error preventing testing:

GUIText has been removed, used UI.Text instead. Seems easy enough to fix. Let’s go into the editor:

So I replaced GUIText with Text and included using UnityEngine.UI for good measure to be sure it works.

The error is gone and we can test the game now and the joypad seems to be working well, though we may want to limit its movement range. 50 should be good:

Yeah, that’s much better!

We won’t be using our hud for the buttons anymore either so go ahead and turn those images off.

Next, we’ll replace the current jump button with our A button graphic, and remove the text.:

Oops! Forgot to rename it to A_Button!

Now we’ll duplicate it and make it a B button!

Not really necessary but I unpacked the button prefab so I can move the B button under the A button. As you may know, Unpacking a prefab separates it from the main prefab. We can always prefab it into a new object when we’re done.

Speaking of being done, I think we’re done setting our buttons up! Tomorrow we’ll hook it into the code!

--

--