It’s the 19th in Australia, and the deadline is the 20th in the UK, so I have kinda 1 1/2 days to go. Need the controller support 100%, so that’s number one priority!

My fall-back if I fail this will be “mouse and kb only”!

Task Planning:

  • Controller menu support: N hours? Never done this so no idea.
  • Not even going to add yesterday’s minor tasks
  • Testing with controller and mouse/kb 1 hour

Dear Google, “unity navigating UI controller rewired”

Found a few links, looks like the event system is what I’m dealing with:

http://answers.unity3d.com/questions/883220/how-to-change-selected-button-in-eventsystem-or-de.html

Since I’m using Rewired there’s a bit I’ve found that looks like I need to setup some actions for UI:

http://guavaman.com/projects/rewired/docs/RewiredStandaloneInputModule.html

Yikes, just started and realised I also need to control drop down menus. I have a bad feeling :) AND! I still have some terrible dual Event Systems happening (one in each scene). After this I’m going to have to do some serious tidying. I barely know what an event system is so yeah… bad feeling!

Rewired Event Systemz

Looks like I need to:

  • Setup Rewired Input Manager and Event System
  • Add new controller actions for UI and maybe a new controller map/category

Ok so I’ve set it all up and I’m pushing controller sticks and d-pads but nothing happening. Kinda dunno if we can even control UIs in another scene or not… I have Rewired in the Manager Scene and the UI to control in the IntroScene. Reading more!

Seems if I click a button then move the controller stick I can use it, think I just need to set a menu option as active to start with, which is annoying as it’s in a different scene!

Moved some stuff into the Manager scene so it’s easier to reference, now we start with the NEW GAME button selected, and can select menu options but not Action any buttons. 1 hr so far.

Action button working (typo!) as well as drop-down menus, amazingly. Refactoring a bunch of stuff now that scripts and objects were moved around. Getting there! 30 mins

While testing this, I realised that if the game will be in a noisy hall and/or someone isn’t wearing headphones or doesn’t wanna listen to the story, they’ll think the long intro is a bug, or boring or whatever. Anyway, adding a button to skip the intro narration! Functionality already exists for debugging so… 5 mins.

Ack! Gross code! Again I need PlayerControls in my manager scene, but really can’t right now, no time! Maybe I can whack something into the Event System to handle this for now, nfi!

Trying to just ‘whack in’ PlayerControls in the intro scene but bad things are happening. Functionality already exists 5 mins ehhhh? Whoops again! 30 mins later and I’ve mostly got this working using some if(introStarted) and if(gameLevelStarted) in PlayerControls. All works, except if I hit New Game, and the intro starts, with the mouse it’s fine, but the controller seems to ‘double click’ or something, causing us to insta skip the intro. Can’t see anything in Rewired to cause a button press to be down longer or anything, might fudge a delay into introStarted for now. Done, 5 mins.

Ok, main menu just needs the drop down items to be red when selected and we are done. Boom!

Rewired for In-Game Menu

I think the main thing for this will just be that I have to tell the EventSystem to select Resume every time I hit Esc/Start, so we can cycle through menu options. I’ll cross my fingers anyway. Here’s what Rewired says to do:

void SetSelected(GameObject selectableObject)

{

// Set the currently selected GameObject

EventSystem.current.SetSelectedGameObject(selectableObject);

}

I think I can just grab

EventSystem.current.SetSelectedGameObject(selectableObject);
and force it to always be Resume? This isn’t a complex menu or anything…

As usual, and probably because my code is a terrible mess, to cut a long story short, there’s lots of broken things happening. The starting menu appears in the tutorial/planet scenes, somehow the ingame menu is appearing in the Intro screen on restart and more! It’s 130 so taking a lunch break.

Lunch

2pm restart. Wondering if I should be trying harder to write good code right now instead of panic rushing stuff. Have a feeling I’ll be working a couple of late nights…

40 minutes in and things are a little cleaner, but still these problems:

  • Restarting doesn’t turn the Quality/Res/NewGame Canvas back on
    • If I manually turn it on and try and press New Game there’s a bunch of null refs from unrelated stuff.
  • When we restart, we can hit escape and the in-game menu appears… 10 mins

Slowly moving everything into sane places in my code, mostly in SceneSetup and LoadEXOScene places instead of just blammed in dumb places with similar function names in an attempt to confuse myself as much as possible.

CofffeeeeeeEeEeeeee! 10 mins

Ok things are looking good! The restart() loop is working fine now except the narration isn’t restarting properly.

My First OnDisable() Ever

I swear, first time I’ve ever done one… to try and handle resetting vars for Restart(). #unitytips4pros

Seriously the fact I’ve never used this is so ridic!

Shortly followed by me writing this comment to myself in my code: //we never disable this script YOUUUUUU!!!

My Dumbest OnDisable() Ever

void LoadTutorialLevel()
{
OnDisable(); //weeeeeeeee!
GameManager.instance.LoadEXOScene(“LoopFacility”);
}

Yeah, I’ll rename this, lol, maybe “ResetVars()”. I’m just being stupid. 45 mins later we can restart and still hear my amazing, self-voiced Aussie-accented narration!

Now the question is, can I restart from ANYWHERE. Testing!

Testing!

  • An asteroid annoyingly blocks the monoliths blue beam, it’s distracting!  Fixed 2 mins
  • Restart works like a treat except once we’ve completed the game/demo, the narrator (and all sound) isn’t restarting.

Watch me Learn!

After we fire the player off at the end of the demo, I mute everything, so…

void OnDisable()
{
MasterAudio.UnmuteEverything();
}

Boom! Task complete dare I say? Now building and testing with mouse/kb and controller.

Test Build Notes

4pm

  • In the build, the dropdowns for Quality and Res are switched around, and resolution was 1180 or something… uh oh! Fixed in 30 mins
  • Ok now it looks fine but I can’t use the interface at all… Can’t change drop downs without them ‘staying’ and obscuring other interface, and New Game doesn’t work at all either. Fixed in 30 mins
  • Even while debug says I’m changing quality settings, the game is definitely just using some middling quality setting. Who knows when the last time was that worked… Anyway fixed in-editor, Fixed 15 mins
  • Getting hit by lightning in tutorial, lawl…  This fixed itself??
  • In the build, we can see menu options but instead of the intro/earth scene in the background it’s pure black. But in editor it’s fine……….!!!!!!!! NFI why the differences. OK maybe being hasty, it’s because in editor I have both scenes open already, so testing with just Manager scene loading first… Fixed 30ish mins.
  • Narration pauses too long in intro, players might skip in 2 seconds  Fixed 2 mins
  • If I leave the intro to complete, I get a bunch of rewired errors – check to see the difference between skipping intro (which I’ve been doing endlessly) and letting it run
    • Odd, further testing didn’t replicate the bug… Fixed

Second Round of Testing Notes

Just played through with the controller, striking out stuff that’s too hard basket/not critical:

  • Low player/environ vol in tutorial
  • Voice intro dull sounding? Muted? “Wrong” mixer settings?
  • Mouse pointer stays till we use controller
  • Fully open tutorial door, we can hit it accidentally
  • Narrator vol is messed up if we go in clouds. Only adjust mixer if narration not happening. Fixed 5 mins
  • Controller > start. Resume. In game menu stays open.   Fixed 10 mins
  • Controller > restart, lost focus on Intro Menu. Need another one of these EventSystem.current.SetSelectedGameObject(selectableObject); Fixed
  • After restart, skip intro, no player or environment volume in tutorial scene
  • Can’t see some lightning bolts hitting us, usually the first one??

Dinner O’Clock

Breaking for dinner at 630, then probably do another hour or two since I’m running out of time. Also just re-read the closing date for LeftField, seems the 20th is closed, dunno if I can submit on the day or not so…

Committed. 815pm

Now to add the EventSystem.SetSelectedObject to the main menu/new game button in case of a restart… I can’t seem to figure out why I can’t get the New Game button to start selected/highlighted on Restarts, which is unfortunate… It may be something to do with the mouse taking focus away from it, like if I ever move the mouse… However I just tried not touching anything, and that made no difference. The Rewired Event System confirms that it is actually selected/highlighted, and I can just press Action to start a New Game, so it may not be highlighting correctly or using the wrong color for some reason. Might Google this.

Found this: http://answers.unity3d.com/questions/1159573/eventsystemsetselectedgameobject-doesnt-highlight.html
The WaitForEndOfFrame coroutine was a winner. 15 mins.
My other worry is if someone knocks the mouse and takes focus away from the menu… I may need to have something that detects mouse or joystick usage and uses that.

For the joystick, perhaps “if selected object in the event system is null, and if any joystick axis/button down, set new game as the selected object”.  Mouse doesn’t need that come to think of it.

Re-activating Menus with Controller if Focus Lost

Was pretty happy with this code, which appears to have worked first go, can now move the mouse off menus/click off menus so they deactivate, then move the d-pad and the menu will come back. Only downside is, controller axis doesn’t do that yet. Gonna try for 5 mins. Wow, things work! Here’s my amazing code, which is mostly other peoples amazing code and plugins!

930PM, going to do another Build Test.

Third Build Test Notes

  • Can’t select resolution with controller.
  • At end of demo, the mouse pointer was sat on a button, and no Controller input would budge it… Maybe “if Controller input, lock mouse cursor”? Then, if mouse movement, unlock? Same happened just in the normal in game menu but multiple buttons would get selected. I’m sure there’s a better way of doing this but for now… HACK ITTTT.

Trying to fix the lock state stuff by detecting mouse or joystick inputs, annnd it also worked pretty well:
Hmm, I think I need a wider blog theme so code it more legible!

Lightning, First Strike Sucks

And is invisible. Pretty important player’s realise quickly they can get struck so fixing… 10:15pm

First I will build, zip, upload, since this could be used now I think (still needs more testing though).

I fired off a bolt in secret at the start of the level, lol. Worked! 30 mins.

Still kinda hard to see the sphere covered in lightning too, gonna tweak that some more as well. The way this plugin works, it’s almost hard to have the settings ‘middle ground’ instead of it looking like it’s off or ONFIRELIGHTNING-APOCALYPSE.

Last Thing(?), Sound Levels

Some weird sound stuff happening, I dunno if I reset anything properly from scene to scene. I think I need to look at MasterAudios Dynamic  Sound Group stuff to see if we are adding new sound groups endlessly or something…

Uh, lightning going off in tutorial again somehow? I did that hacky lightning so it’d go off only on the first planet… also for some reason I can hear wind now… This problem seems intermittent! Leaving it…

The reason we can hear rain in the intro after a restart is, we enter a cloud, hear rain, then restart, and rain isn’t turned off. I OnDisabled() the shiiiit out of it!

Again, the lightning + inclouds sounds appearing randomly in the tutorial is really bad. Gotta investigate at least 15 mins.

11PM

Added some extra things (sceneIsExterior) to try and shield lightning from going off in the tutorial… MasterAudio must also be firing InClouds to get the sound I hear as well, but nfi how it’s fired. There’s no clouds in the tutorial level! HumMmmMmmm

Oh, and the drop down for resolution…

If I can’t get this, no big deal, who has a monitor that isn’t 1920p?! Well the odds someone does for Rezzed just for my game is 0!

Abandoned! Can’t make sense of the code I copy pasted ages ago!

Final Test

Seems to work, ran 2 full games with mouse/kb and 2 with controller, no problems.

Did one more and still feel like sometimes the sphere doesn’t transform into a glider when entering a cloud with 0 charge with glide button held…! Noticed that it costs more to glide than we can recharge, which might have been the reason? But it only seemed a problem on first cloud enter… Tested a little more, still unsure, good enough though – you often get hit by lightning in clouds anyway I guess(!).

Tidying start position so we definitely roll down the hill the right way… And there’s a bit of geometry you can snag on the tutorial.

Zipping and submitting now and calling it a night once that’s done. Now past midnight!

Phewwwf. Maybe I’ll submit then get up at 9-10, do some more tests just to make sure, and I can submit another updated one if I need to.