Tuesday, October 20, 2015

Dev Update #15 - Almost Done. Exit Game Button. Confirmation Dialog Boxes

Exit Game Button

10/18/2015 I added an Exit game button using Application.Quit(); and also moved the Right Panel Buttons off of a Scrollview that wasn't doing anything and redid the anchors for the buttons so they would scale correctly.

Confirmation Dialog Boxes (Modal Windows)

10/20/2015   I added some Modal windows for 6 Reset Game and Exit Game.  I started by watching the part 1 of 3 of the Unity tutorial/live session UI TOOLS: MAKING A GENERIC MODAL WINDOW, and then decided I didn't need such a complex solution for just 2 modal windows, so I hacked together some panels and buttons, copied them, and then modified my original Exit Game and Reset Game button scripts.

The ExitGame script looks like this:

using UnityEngine;
using System.Collections;
public class ExitButton : MonoBehaviour
{
    public GameObject exitModal;
    public GameObject resetModal;
     public void ExitGamePressed()
        {
            if (resetModal.activeSelf == false)
            exitModal.SetActive(true);
        }
     public void ExitGame()
     {
         Application.Quit();
   
     }
     public void ClosePanel()
     {
         exitModal.SetActive(false);
     }
}

The ResetGame script is mostly the same except with "Reset" in place of "Exit" and instead of Application.Quit, it calls the ResetGame function from BoardManager.  All the code I added to the two scripts is almost the same between both scripts, which seems wasteful and I'm sure there's a better way, but I'm more concerned with getting it functional. I may rewrite later.

The appropriate functions are then assigned to the appropriate button's onClick events and the appropriate GameObjects are assigned to the scripts.  Both exitModal and ResetModal are set to inactive in the editor.

What's Next

I'm pretty much done.  I've made a build and I'm testing it.  Currently the key press "P" will pause/unpause and "M" will pause/unpause the music which is a problem when typing in todos, so I'll fix that.  I'll readjust a few things in the UI to try to make them look a little more professional.  I don't really like the way the text looks. I might try to make that look a little nicer.  Some graphics on the UI elements would be nice, but I don't think I'm going to touch that for the prototype.

There's always more I could do, but as far as I'm concerned, I've accomplished all my goals.  So once, I've polished things up a little, and done a little testing, I'm going to make Windows, Mac OSX, linux, and maybe Android builds and release them all simultaneously on this website.  That should be very soon.
Running in a Build

No comments:

Post a Comment