Audio options. The persistence nightmare.

I mentioned last time I was going to make a shop and look into the need for an options menu. After looking at similar games and thinking about it, I decided an options menu was definitely more important.

The first option I already knew I was going to include. I wanted to have a way for the player to remove the backgrounds, and simply play against a grey screen. I figured this might help performance issues on some phones and be helpful to some of the more 'hardcore' players, by giving them less distractions.

I looked at similar games and the only option I really saw that came up time and time again was audio control. So I decided to implement a way to control the sound effects and music. 

In my previous post I talked about how pictures should be substituted for words as often as possible, thereby removing the language barrier that would otherwise stop more players getting in to the game. Therefore, I used no words in the options menu. Instead relying on symbols (like Prince) and thereby making my game more accessible to an international audience (also like Prince). 

In the end, I came up with 7 symbols. One for the Options menu and one for the shop (which I will deal with later). within the options menu, I have 3; one for music volume, one for SFX and one for the grey screen option, as well as a back button. Can you guess which one is which?

the options menu ended up looking like this:

I'm happy with it. I think it's easy to interpret, looks good and includes everything you'd need. The pixelation on the circles should disappear on actual phone screens as all the images are mip-maps enabled. The blur shader was one I found on a forum, I couldn't tell you how to make it, shaders are the height of black magic in Unity.

It occurred to me that since the scene resets on game over, what ever the player sets these options as would have to persist through scenes. For some reason this took me the best part of a day to figure out. I knew it would involve some coding with Dontdestroyonload and static variables but I couldn't figure out how to do them. I don't know if it was me being tired or just plain stupid but eventually I figured it out. heres my code for the persistent menuManager.

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class menuManager : MonoBehaviour {
    public Button shopButton;
    public Button optionButton;

    public Slider musicVol;
    public Slider SFXVol;
    public Toggle background;

    public GameObject optionsMenu;

    controller cont;

    public static bool workHours;
    // Use this for initialization
    void Start () {
        if (onOrOff.onoroff == false) {
            background.isOn = false;
        if (onOrOff.onoroff == true) {
            background.isOn = true;
        musicVol.value = PlayerPrefs.GetFloat ("musicVol", 1);
        SFXVol.value = PlayerPrefs.GetFloat ("SFXVol", 1);


        cont = FindObjectOfType<controller> ();

        workHours = true;

    // Update is called once per frame
    void Update () {

        if (workHours == true) {
            shopButton.interactable = true;
            optionButton.interactable = true;
        } else if (workHours == false) {
            shopButton.interactable = false;
            optionButton.interactable = false;;

    public void OptionsMenuOn () {
        cont.disabled = true;
        Time.timeScale = 0;
        optionsMenu.SetActive (true);
        shopButton.interactable = false;
        optionButton.interactable = false;

    public void Back () {
        optionsMenu.SetActive (false);
        shopButton.interactable = true;
        optionButton.interactable = true;
        Time.timeScale = 1;

    public void musicChange(float vol) {
        PlayerPrefs.SetFloat ("musicVol", vol);

    public void SFXChange (float vol) {
        PlayerPrefs.SetFloat ("SFXVol", vol);

The onOrOff script is simply attached to the backgrounds and checks if they are visible or not.

It occurred to me that after making these settings, the only way to test them would be to add audio to the game. I am awful with music, I can't even whistle. I thought the Bassoon was a species of Snake. Nevertheless, I jumped in head first and got started. 

to begin with I used a site called BFXR to generate some 16 bit style sound effects. The site is incredibly easy to use and I highly recommend it. I just hit randomise a couple of hundred times and picked out the sounds I liked (Science). Heres the sound generated when the player is stunned.

I also used some creative commons license zero sounds to flesh out the audio range as well. I set myself a set of rules at the beginning of the project based on what I think the key components of a  successful addicting game are. One of them was sounds rich in bass. I made sure to use a low pass filter on these sounds to stick to this rule.

I wanted to put a bit of myself into the project so I decided to use my own voice as a reward sound when the player reaches certain distance milestones. I recorded myself reading a list of synonyms for "good job" and picked out the ones I felt were best. I tried to model the audio in the style of the Halo 3 multiplayer V.O. I filtered and stretched the audio before putting it into the project. I may revisit these sounds in the future If I have time and can get my hands on a professional mic.

Finally,  I had to come up with a theme tune. By chance I stumbled across a great program called Bosca Ceoil. The hardest thing about this program is the pronunciation of the god-damn name. It's that intuitive. It's great for making little chip-tune songs and I think it's potential is limitless. So being me, I quickly knocked together a distinctly average theme tune.

I mean, it's not bad. But it's definitely not great and certainly not catchy(catchee?). If i'm using my own options menu to turn it down during testing then I certainly think I'll be revisiting this.

Finally, heres a bit of in game footage, sorry for the mouse floating around the screen and the lack of sound. I'll try to get some better videos up in the future.

There's really not much left to do in the project now. I need to implement power-ups. A shop to buy extras and some sort of lives system. I'm anticipating the lives system might be a bit of a b*tch but apart from that I'm on the home-run... Before I have to start really marketing.

On a side note, I know it's quite cheeky, but if you enjoy what you read here and are interested in the project, please share it with your friends! it's a real boost actually noticing people take an interest and visit this blog. Thanks for reading.