Unity with WiiU

Discussion in 'Wii U - Hacking & Backup Loaders' started by handy333, Mar 8, 2016.

  1. handy333
    OP

    handy333 GBAtemp Regular

    Member
    122
    38
    Sep 8, 2010
    United States
    Over in Wonderlust
    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.
     
  2. lordelan

    lordelan GBAtemp Advanced Maniac

    Member
    1,677
    477
    Jan 4, 2015
    Gambia, The
    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:
    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?
     
  3. handy333
    OP

    handy333 GBAtemp Regular

    Member
    122
    38
    Sep 8, 2010
    United States
    Over in Wonderlust
    After years of working with this. I actually got some things to work except for the rumble. With the buttons I just use the inspector.
    I'm not entirely sure how you do it with just scripting.
     
    lordelan likes this.
  4. lordelan

    lordelan GBAtemp Advanced Maniac

    Member
    1,677
    477
    Jan 4, 2015
    Gambia, The
    And how do you do it in the inspector?
     
  5. mochy

    mochy Newbie

    Newcomer
    5
    0
    Apr 26, 2017
    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.
     
  6. lordelan

    lordelan GBAtemp Advanced Maniac

    Member
    1,677
    477
    Jan 4, 2015
    Gambia, The
    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.
     
    mochy likes this.
  7. mochy

    mochy Newbie

    Newcomer
    5
    0
    Apr 26, 2017
    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.
     
  8. lordelan

    lordelan GBAtemp Advanced Maniac

    Member
    1,677
    477
    Jan 4, 2015
    Gambia, The
    lol :D
     
  9. handy333
    OP

    handy333 GBAtemp Regular

    Member
    122
    38
    Sep 8, 2010
    United States
    Over in Wonderlust
    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.
     
    lordelan likes this.
  10. lordelan

    lordelan GBAtemp Advanced Maniac

    Member
    1,677
    477
    Jan 4, 2015
    Gambia, The
    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! :)
     
  11. handy333
    OP

    handy333 GBAtemp Regular

    Member
    122
    38
    Sep 8, 2010
    United States
    Over in Wonderlust
    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, Apr 27, 2017
  12. lordelan

    lordelan GBAtemp Advanced Maniac

    Member
    1,677
    477
    Jan 4, 2015
    Gambia, The
    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;
     
  13. lordelan

    lordelan GBAtemp Advanced Maniac

    Member
    1,677
    477
    Jan 4, 2015
    Gambia, The
    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
    
     
    Voxel likes this.
  14. handy333
    OP

    handy333 GBAtemp Regular

    Member
    122
    38
    Sep 8, 2010
    United States
    Over in Wonderlust
    That's going to take a while for me to wrap my head around. But none the less it's just what I needed. I've been trying to do this for the longest. I appreciate you taking the time.
     
    lordelan likes this.
  15. mochy

    mochy Newbie

    Newcomer
    5
    0
    Apr 26, 2017
    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:
     
  16. lordelan

    lordelan GBAtemp Advanced Maniac

    Member
    1,677
    477
    Jan 4, 2015
    Gambia, The
    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.
     
    mochy likes this.
  17. mochy

    mochy Newbie

    Newcomer
    5
    0
    Apr 26, 2017
    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.
     
  18. lordelan

    lordelan GBAtemp Advanced Maniac

    Member
    1,677
    477
    Jan 4, 2015
    Gambia, The
    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.
     
  19. handy333
    OP

    handy333 GBAtemp Regular

    Member
    122
    38
    Sep 8, 2010
    United States
    Over in Wonderlust
    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, Apr 30, 2017
  20. lordelan

    lordelan GBAtemp Advanced Maniac

    Member
    1,677
    477
    Jan 4, 2015
    Gambia, The
    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