Hacking Unity with WiiU

lordelan

Well-Known Member
Member
Joined
Jan 4, 2015
Messages
5,784
Trophies
1
Age
44
XP
6,509
Country
Germany
Has anyone had any luck using any of the WiiU input features with Unity?
I can only get the axes/analogs to recognize input and the touch screen.
I'm glad that there already is a thread so I don't have to open one.
As everyone can sign up for the Ninty dev portal we should discuss way more about Unity here as it's very cool.
I'm trying to port a small Tower Defense game that I made for Windows to Wii U right now.
After putting in using UnityEngine.WiiU; at the top I'm able to access GamePadButton (UnityEngine.WiiU.GamePadButton) but I can't get it to work.
Here's what I had before:
Code:
if (Input.GetKey(KeyCode.W))
        {
            transform.Translate(Vector3.up * cameraSpeed * Time.deltaTime);
        }
Here's what I thought would be working but it's not:
Code:
if (Input.GetKey(KeyCode.W) || (Input.GetButton(GamePadButton.Up)))
        {
            transform.Translate(Vector3.up * cameraSpeed * Time.deltaTime);
        }
It's giving me the following error:
Error CS1503 Argument 1: cannot convert from 'UnityEngine.WiiU.GamePadButton' to 'string'
I just don't get it.
KeyCode is an enum and GamePadButton is too. Both have (in their definitions) all possible keys assigned to the numbers.
What am I missing?
 

mochy

Member
Newcomer
Joined
Apr 26, 2017
Messages
5
Trophies
0
Age
27
XP
44
Country
First of all, sorry for my bad English D:

Do you view into unity tutorials on nintendo developer?
They put the WiiU.GamePadState on api that implements the majority sensors, buttons, errors...for gamepad. Maybe you found rumble too.

I have other issue if you could help me:
I'm starting with unity for wiiu, but when export the project (one scene for example), export folders _Intermediate, code, content and meta, but only on _Intermediate have files, the others are empty.
I tred with all export: master, unpackaged, disk...but I have same result.
 

lordelan

Well-Known Member
Member
Joined
Jan 4, 2015
Messages
5,784
Trophies
1
Age
44
XP
6,509
Country
Germany
First of all, sorry for my bad English D:

Do you view into unity tutorials on nintendo developer?
They put the WiiU.GamePadState on api that implements the majority sensors, buttons, errors...for gamepad. Maybe you found rumble too.

I have other issue if you could help me:
I'm starting with unity for wiiu, but when export the project (one scene for example), export folders _Intermediate, code, content and meta, but only on _Intermediate have files, the others are empty.
I tred with all export: master, unpackaged, disk...but I have same result.
Yep. Install GHS_MULTI (Multi) from Ninty's Dev Portal.
When you've done open up your project, head to edit -> preferences and set the path for MULTI to its install folder.
Had that issue as well. Worked afterwards and instantly launched (unpackaged) in Loadiine then. :)

Info: Multi is needed to compile for Wii U in general so it's needed for Unity as well.
 
  • Like
Reactions: mochy

mochy

Member
Newcomer
Joined
Apr 26, 2017
Messages
5
Trophies
0
Age
27
XP
44
Country
Yep. Install GHS_MULTI (Multi) from Ninty's Dev Portal.
When you've done open up your project, head to edit -> preferences and set the path for MULTI to its install folder.
Had that issue as well. Worked afterwards and instantly launched (unpackaged) in Loadiine then. :)

Info: Multi is needed to compile for Wii U in general so it's needed for Unity as well.

Thanks a lot, yes, I know, but I had an epic mistake and obvious: I put the GHS_MULTI directory on installer folder :lol:
I'm very excited. When I arrive at home, I try it.
 

handy333

Well-Known Member
OP
Member
Joined
Sep 8, 2010
Messages
122
Trophies
0
Age
32
Location
Over in Wonderlust
Website
projectrisingsun.weebly.com
XP
265
Country
United States
If you go to Edit > Project Settings > Input you'll see the Unity Input or whatever they call it. I'll give an example for the A button. You may want to lock the inspector in place. There is a small padlock on the top left hand side of the inspector panel. Click that after you have opened the Project Settings Input Panel.

  • Name: a
  • Descriptive Name: A button on WiiU Gamepad
  • -
  • -
  • "IMPORTANT" Positive Button: joystick 2 button 2
  • -
  • Alt Positive Button: "It's up to you really I just put e"
  • //Not too sure but I just copied the other keys like FIRE because it's just a normal button.
  • Gravity: 1000
  • Dead: 0.001
  • Sensitivity: 1000
  • Snap: [✔]
  • //Back to normal
  • Invert: -
  • Type: Key or Mouse Button
  • Axis: X Axis
  • Joy Num: JoyStick 2 // For the wiiu gamepad

Now you can basically copy and paste this for the rest of the buttons. But what you would want to change is the "Important" Positive Button: joystick 2 button (x).
joystick 2 button 2 just so happens to be the a button on the wiiu gamepad. Here's a reference to it.

Help > Unity Manual WiiUPlayer...

On the left hand side...

Platform Specific > WiiU > WiiU Scripting > WiiU Joystick Aliases and Axes

Here is where all of the buttons for all of the controllers supported by the wiiU.

I hope this was helpful.
 
  • Like
Reactions: lordelan

lordelan

Well-Known Member
Member
Joined
Jan 4, 2015
Messages
5,784
Trophies
1
Age
44
XP
6,509
Country
Germany
Thank you very much. I found out how to do it in the code as well:
Code:
using UnityEngine;
using WiiU = UnityEngine.WiiU;

public class gamePadInputTest : MonoBehaviour
{
    WiiU.GamePad gamePad;
    void Start()
    {
        // Create a GamePad object
        gamePad = WiiU.GamePad.access;
    }
    void Update()
    {
        // Get the new state of the GamePad
        WiiU.GamePadState gamePadState = gamePad.state;

        if (gamePadState.gamePadErr == WiiU.GamePadError.None) 
        {
            // Check for the A button
            if (gamePadState.IsTriggered(WiiU.GamePadButton.A)) 
            { 
                // The A button was pressed
            }
            
            // Read data from the gyroscope
            Vector3 gyroData = gamePadState.gyro;
            
            // Read data from the left stick
            Vector2 leftStick = gamePadState.lStick; 
        }
    }
}
As I am someone who prefers doing things in code this seems better for me but it's great to have your way as a fallback! :)
 
  • Like
Reactions: XylaTV

handy333

Well-Known Member
OP
Member
Joined
Sep 8, 2010
Messages
122
Trophies
0
Age
32
Location
Over in Wonderlust
Website
projectrisingsun.weebly.com
XP
265
Country
United States
I'm glad I could help. Also you may have taught me something too so thanks. Now I just have to figure out the rumble thing.

*Edit*
If I'm not mistaken, you could do something like this:
(can't find the code button)
using UnityEngine.WiiU;

Instead of this:
using WiiU = UnityEngine.WiiU;

If there is a difference, please let me know.
 
Last edited by handy333,

lordelan

Well-Known Member
Member
Joined
Jan 4, 2015
Messages
5,784
Trophies
1
Age
44
XP
6,509
Country
Germany
I'm glad I could help. Also you may have taught me something too so thanks. Now I just have to figure out the rumble thing.

*Edit*
If I'm not mistaken, you could do something like this:
(can't find the code button)
using UnityEngine.WiiU;

Instead of this:
using WiiU = UnityEngine.WiiU;

If there is a difference, please let me know.
I'm not sure whether my methods only get's compiled when I do a Wii U build.
However I copied that line over from Ninty's official tutorial section while I'm using yours most of the time:
Code:
using UnityEngine.WiiU;
 

lordelan

Well-Known Member
Member
Joined
Jan 4, 2015
Messages
5,784
Trophies
1
Age
44
XP
6,509
Country
Germany
Now I'm going to help you with the rumble feature.
You can pass a maximum of 15 bytes at once to the GamePad.
15 bytes are equal to 1 second rumble effect. That being said you can write something like this:
Code:
byte[] pattern = new byte[patternLength];
for (int i = 0; i < pattern.Length; ++i)
{
    pattern[i] = 0xff;
}
Then you should instantiate the GamePad:
Code:
WiiUGamePadState gamePadState = WiiUInput.GamePadState(0);
Afterwards you could use the following line to have a 1 second rumble:
Code:
gamePadState.ControlMotor(pattern, pattern.Length * 8);
To have it rumbling for 2,5 seconds you would do this instead:
Code:
gamePadState.ControlMotor(pattern, pattern.Length * 8);
gamePadState.ControlMotor(pattern, pattern.Length * 8);
gamePadState.ControlMotor(pattern, pattern.Length * 4);
I think you got it. ;)

For Wii Remotes use
Code:
WiiUInput.PlayRumbleMotor
instead of
Code:
WiiUGamePadState.ControlMotor
 
  • Like
Reactions: Deleted User

mochy

Member
Newcomer
Joined
Apr 26, 2017
Messages
5
Trophies
0
Age
27
XP
44
Country
Finally, I follow the instructions on nindev, and when put path with cmd (I give it a try)...don't do it please :blush:, best on windows interface, because my w10 crash, and I never turn on pc normally, only on my linux partition.
And well, I format now the windows that it was time. I repeated the steps and now very well.
My dude now, that I build the project->generates a new folder called _AOT, and the code it's the only that have files inside.
Could you send me a example project for wii u(via-private)? Maybe the problem it's my scene...D:
 

lordelan

Well-Known Member
Member
Joined
Jan 4, 2015
Messages
5,784
Trophies
1
Age
44
XP
6,509
Country
Germany
Finally, I follow the instructions on nindev, and when put path with cmd (I give it a try)...don't do it please :blush:, best on windows interface, because my w10 crash, and I never turn on pc normally, only on my linux partition.
And well, I format now the windows that it was time. I repeated the steps and now very well.
My dude now, that I build the project->generates a new folder called _AOT, and the code it's the only that have files inside.
Could you send me a example project for wii u(via-private)? Maybe the problem it's my scene...D:
Sure. But you don't anything but code, content and meta. And you would have to adjust the meta.xml by yourself.
Maybe there's a setting in Unity to do so (haven't looked yet) but I did the complete meta folder content with Notepad++ and Photoshop by myself.
 
  • Like
Reactions: mochy

mochy

Member
Newcomer
Joined
Apr 26, 2017
Messages
5
Trophies
0
Age
27
XP
44
Country
Sure. But you don't anything but code, content and meta. And you would have to adjust the meta.xml by yourself.
Maybe there's a setting in Unity to do so (haven't looked yet) but I did the complete meta folder content with Notepad++ and Photoshop by myself.

Thanks a lot!
Maybe with oxygen, it's best for meta .xml files, I'm going to try soon whenever I can.
Good luck. On future it's possible that I know more and can apport it to you as a sign of gratitude.
 

lordelan

Well-Known Member
Member
Joined
Jan 4, 2015
Messages
5,784
Trophies
1
Age
44
XP
6,509
Country
Germany
Thanks a lot!
Maybe with oxygen, it's best for meta .xml files, I'm going to try soon whenever I can.
Good luck. On future it's possible that I know more and can apport it to you as a sign of gratitude.
You're welcome.
I guess we're both a bit late at "Unity for Wii U" but I keep playing around with it and I would be glad if this thread would be kept alive. :)
I mean the internet is full of Unity tutorials. It's simple to use, easy to learn and could be built for all relevant platforms.
And all you gotta do is register for Ninty's dev portal (which is free) and test your game in Loadiine or even Cemu.
You just can't share your games as long as you don't buy a devkit due to copyrights but that's okay for now.
Just let us post everything Wii U related here to help each other. :)
It's really really satisfying by the way to use GameCube Controllers (even with rumble) for Unity games although that was not intended thanks to Maschell and his fantastic HID to VPAD.
 

handy333

Well-Known Member
OP
Member
Joined
Sep 8, 2010
Messages
122
Trophies
0
Age
32
Location
Over in Wonderlust
Website
projectrisingsun.weebly.com
XP
265
Country
United States
You're welcome.
I guess we're both a bit late at "Unity for Wii U" but I keep playing around with it and I would be glad if this thread would be kept alive. :)
I mean the internet is full of Unity tutorials. It's simple to use, easy to learn and could be built for all relevant platforms.
And all you gotta do is register for Ninty's dev portal (which is free) and test your game in Loadiine or even Cemu.
You just can't share your games as long as you don't buy a devkit due to copyrights but that's okay for now.
Just let us post everything Wii U related here to help each other. :)
It's really really satisfying by the way to use GameCube Controllers (even with rumble) for Unity games although that was not intended thanks to Maschell and his fantastic HID to VPAD.

The 3DS development still has it's thing. I'll probably port my game over if it's too late for the wiiU already. It probably won't take much effort because I'm pretty much using placeholder graphics now. I don't think I can test my games on CEMU because It crashes every time I try to load mine but as expected it works really good on my wiiu.
 
Last edited by handy333,

lordelan

Well-Known Member
Member
Joined
Jan 4, 2015
Messages
5,784
Trophies
1
Age
44
XP
6,509
Country
Germany
The 3DS development still has it's thing. I'll probably port my game over if it's too late for the wiiU already. It probably won't take much effort because I'm pretty much using placeholder graphics now. I don't think I can test my games on CEMU because It crashes every time I try to load mine but as expected it works really good on my wiiu.
Yeah I'm going to build my games for Wii U and 3DS as well but as I love sitting on my couch, Wii U always comes first. :P
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    SylverReZ @ SylverReZ: @Maximumbeans, Morning MaximumBeans.