Can anyone help pretty please? Seems like a simple toggle question.

I’ve made a custom GUILayout option for an array of bools so that they lie horizontal, I now have no function of the toggle button, just turning it on and off. I suspect I’ve been a fool somewhere and locked it out of use, but I was struggling with this till late last night pulling out my hair!

The important part I think I’m messing up is:

public static void ShowButtons (SerializedProperty list, int index, int numberOfSlots) {

        bool[] nOff = new bool[numberOfSlots];

        for (int i = 0; i < numberOfSlots; i++) {

            if (GUILayout.Toggle(nOff[i], buttonContent, miniButtonWidth))
                {

                if (nOff [i] != true) {
                    nOff[i] = true;
                    Debug.Log (nOff[i]);
                }
                else
                {
                    nOff[i] = false;
                }
                Debug.Log(index); // The Row
                Debug.Log(i); // The Collumn
                }   
            }
        }

But I can’t actually turn on and off the bools in the inspector, when I debug I see each button knows it’s own row and column, it’s just forgotten how to turn itself on and off. What am I missing, I’m going slightly crazy tracking this down!

Here’s the whole thing:

using UnityEditor;
using UnityEngine;
using System;

[Flags]
public enum EditorListOption {
    None = 0,
    ListSize = 1,
    ListLabel = 2,
    ElementLabels = 4,
    NumSlots = 16,
    Buttons = 16,
    Toggles = 16,
    Default = ListSize | ListLabel | ElementLabels,
    NoElementLabels = ListSize | ListLabel,
    All = Default | Buttons | NumSlots
}

public static class EditorList {

    private static GUIContent

        buttonContent = new GUIContent("+");

    private static GUILayoutOption miniButtonWidth = GUILayout.Width(20f);

    public static void Show (SerializedProperty list, EditorListOption options = EditorListOption.Default) {
        if (!list.isArray) {
            EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error);
            return;
        }

        bool
            showListLabel = (options & EditorListOption.ListLabel) != 0,
            showListSize = (options & EditorListOption.ListSize) != 0;

        //numSlots =

        if (showListLabel) {
            EditorGUILayout.PropertyField(list);
            EditorGUI.indentLevel += 1;
        }
        if (!showListLabel || list.isExpanded) {
            SerializedProperty size = list.FindPropertyRelative("Array.size");
            if (showListSize) {
                EditorGUILayout.PropertyField(size);
            }
            if (size.hasMultipleDifferentValues) {
                EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
            }
            else {
                ShowElements(list, options);
            }
        }
        if (showListLabel) {
            EditorGUI.indentLevel -= 1;
        }
    }

    private static void ShowElements (SerializedProperty list, EditorListOption options) {
        bool
            showElementLabels = (options & EditorListOption.ElementLabels) != 0,
            showButtons = (options & EditorListOption.Buttons) != 0;

        for (int i = 0; i < list.arraySize; i++) {
            if (showButtons) {
                EditorGUILayout.BeginHorizontal();
            }
            if (showButtons) {
                ShowButtons(list, i, numberOfSlots:16);
                EditorGUILayout.EndHorizontal();
            }
        }
        if (showButtons && list.arraySize == 0 && GUILayout.Toggle(true, buttonContent, EditorStyles.miniButton)) {
            list.arraySize += 1;
        }
    }

    public static void ShowButtons (SerializedProperty list, int index, int numberOfSlots) {

        bool[] nOff = new bool[numberOfSlots];

        for (int i = 0; i < numberOfSlots; i++) {

            if (GUILayout.Toggle(nOff[i], buttonContent, miniButtonWidth))
                {

                if (nOff [i] != true) {
                    nOff[i] = true;
                    Debug.Log (nOff[i]);
                }
                else
                {
                    nOff[i] = false;
                }
                Debug.Log(index); // The Row
                Debug.Log(i); // The Collumn
                }   
            }
        }
}

and

using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(ScriptName)), CanEditMultipleObjects]

//[CustomEditor(typeof(SamplerLoops))]

public class ListTesterInspector : Editor {

    public override void OnInspectorGUI () {
        serializedObject.Update();
        EditorList.Show(serializedObject.FindProperty("bools"), EditorListOption.Toggles | EditorListOption.ListSize);
        //EditorList.Show(serializedObject.FindProperty("loops1"), EditorListOption.Toggles | EditorListOption.ListSize);
        serializedObject.ApplyModifiedProperties();
    }
}

If anyone could help I would be insanely grateful.

Damn another thread just talking to myself.

I’m going slightly mental with this problem please help! It seems so simple from the outside, am I being stupid or is this a specifically difficult task of setting a bool to on or off??

public static void ShowButtons (SerializedProperty list, int index) {

        int numberOfSlots = 16;

        bool[ , ] nOff = new bool[numberOfSlots,numberOfSlots];

        for (int i = 0; i < numberOfSlots; i++) {

            if (GUILayout.Toggle(nOff[i , index], buttonContent, miniButtonWidth))
                {
                if (nOff [i, index] != true)
                {
                    nOff [i, index] = true;
                    GUILayout.Toggle(nOff[i , index], buttonContent, miniButtonWidth); // THIS IS DRIVING ME CRAZY WHY WON'T THIS TOGGLE SET!!
                    Debug.Log (nOff [i, index]);
                }

                if (nOff [i, index] = true)
                {
                    nOff [i, index] = false;
                    GUILayout.Toggle(nOff[i , index], buttonContent, miniButtonWidth);
                    Debug.Log("Col =" + i + "Row =" +index);
                }
              
                }  
            }
        }

Toggle returns the new value when clicked. You aren’t actually assigning that value. Your nOff value won’t ever be set.

Note the example here:

I don’t think I quite understand, in the reference they assign private bools to each toggle and set them with…

toggleTxt = GUILayout.Toggle(toggleTxt, "A Toggle text");

I thought I was doing that with this and the bits that follow:

bool[ , ] nOff =newbool[numberOfSlots,numberOfSlots];

I think it’s the array I’m getting confused with, as I didn’t want to explicitly list everything, I just wanted to wrap it up in for loop.

I don’t want to do anything specific with the buttons in that code. I just wanted to change the appearance/layout of toggles for an array of bools and be able to access/read each container from another script, I just wanted them to work the same as any other bool array does.

Thank you very much for helping ZombieGorrila, seems like you’ve seen what the flaw is, I still can’t see what is wrong as I’m a giant dum dum. Seems like I’d need to take out the if loop and assign it to itself, would this be it:

if (GUILayout.Toggle(nOff[i , index], buttonContent, miniButtonWidth))
                {
                    nOff[i , index] = GUILayout.Toggle(nOff[i , index], buttonContent, miniButtonWidth); 
                    Debug.Log (nOff [i, index]);
                }

My conceptual problem is I have three scripts, the extension of the editor, the custom options and the final script i’m aiming this at, and I’m not sure how to get the latter two talking together smoothly. I’ve seen people mention things like an interface would that help in this case?

I thought this would be relatively simple, it’s taking me three days to work out how to turn a switch on.

For instance make a bool[ ] array, you can switch the toggles on and off without having to set them to anything, why would I have to set them to read themselves in the editorOptions script? I’m just trying to override the appearance not the functionality, I’m not sure how to wrap my head around this.

Sorry meant to post this:
http://docs.unity3d.com/ScriptReference/EditorGUILayout.Toggle.html
The editor version.

Yes, they do just show creating a local bool and using it, but that is just because they are only providing an example of the toogle functionality. But what it illustrates is that Toggle takes an existing bool value (wherever it may originate from and can be used to flip that bool if the widget is clicked.

Toggle only returns the value of bool that is passed in, if clicked, returns the opposite. It does not set it. In that block you are basically doing things twice by having two toggles.
So it should be only something like this:

                 nOff[i , index] = GUILayout.Toggle(nOff[i , index], buttonContent, miniButtonWidth);

you don’t need the if statement wrapper. in fact if this were working properly you would have two toggle at times.

However, looking at your previous code, there are some other problems as well. You are passing in “list” which is probably supposed to be your list of bools from the script. But you never you use it. You create a new empty array of bools and loop through that. Nothing is being read, or applied. Since a new empty list of bools are all going to default to false, everything will always be false because it is being reset to false every frame.

You could do it with an interface. But probably unnecessary, that is more useful for broader application of concept/feature. If the goal is just to restyle some controls in the editor, you can just do it with the editor for the class where you set them. Can you explain better what the use is?

Ahh ok, the purpose is complete stupid. I’ve made a 16 step sequencer for arranging drums and loops in the inspector, when you make a bool array it appears vertically, I would like to have each line of the step sequencer not take up so much space in the inspector, at the moment it’s 16 lines when it could be one.

I’ve been researching further and I think the main bits I need to get my head around is serialized property, custom property drawer, begin Horizontal and end Horizontal, the OnGUI stuff is slightly baffling it’s seems to be written in a slightly unfamiliar way, looks more alien than the C# bits i’m used to looking at.

I know it should something along these lines:

using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomPropertyDrawer(typeof(BooleanArray))]
public class BoolDrawer : PropertyDrawer {

    public override void OnGUI (Rect position, SerializedProperty list, GUIContent label)
    {

    //    showToggle = true;
        ShowToggle = EditorGUILayout.Toggle("wtf", ShowToggle);

        for (int i = 0; i < list.arraySize; i++) {
            if (showToggle) {
                GUILayout.BeginHorizontal ();

            }
            if (showToggle) {
                (ShowToggle)
                GUILayout.EndHorizontal ();
            }
        }
    }
        //label = EditorGUI.BeginProperty (position, label, property);
        //Rect contentPosition = EditorGUI.PrefixLabel (position, label);
        //EditorGUI.indentLevel = 0;
        //EditorGUI.PropertyField (contentPosition, property.FindPropertyRelative ("boolean"), GUIContent.none);
        //EditorGUI.EndProperty ();
   
}

The examples say something like ShwBtn = EditorGUILayout.Toggle(“label”, ShwBtn); but I haven’t been able to get that to work, assigning the variable to itself and confusing even more when there’s an array, most of the examples are singular or two toggle cases.

I think that’s the main bit that has been confusing me how to deal with multiple elements and assign their value

Damn I totally didn’t see your first message just the second one. Sorry for the thoughtless response earlier.

Ok I’ve had another crack and cleaned up the list version of the bool arrays, and still get to the end of the loop scratching my head about assigning the bool array back to itself, I’m glad i’m not going crazy and the answer is something along the lines of nOff = Toggle(nOff*) although no joy just yet.*
I’ve tried taking out of the If statement wrapper like you mentioned, but I put it there to only let something through when something had been happened, otherwise if I take it out it seems like it’s just endlessly going for it!
I wondering if the thing that could be messing me up is not initialising the bool arrays, the examples I’ve seen set the array like {true, true, true} etc, that’s the bit just by looking comparatively at the examples that is different.
On the last note of the message I missed are you saying I’m looping round things that aren’t there? I would prefer to define how large the array from the script I’m directing it at, as opposed to defining the size from show toggles, or pass it a number to define the number of slots. But i’m slightly confused about handling these arrays from script to script.
```csharp
*using UnityEditor;
using UnityEngine;
using System;

[Flags]
public enum EditorListOption
{
ListSize = 16,
ElementLabels = 2,
Toggles = 16
}

public static class EditorList

{
public static void Show (SerializedProperty list, EditorListOption options)
{
bool
showListSize = (options & EditorListOption.ListSize) != 0,
showTgls = (options & EditorListOption.Toggles) != 0,
showElementLabels = (options & EditorListOption.ElementLabels) != 0;

    EditorGUILayout.PropertyField (list);
    EditorGUILayout.PropertyField (list.FindPropertyRelative ("Array.size"));

    for (int i = 0; i < list.arraySize; i++) {
        if (showTgls) {
            EditorGUILayout.BeginHorizontal ();
        }
        if (showElementLabels) {
            EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));
        } else {
            EditorGUILayout.PropertyField (list.GetArrayElementAtIndex(i), GUIContent.none);
        }
        if (showTgls) {
            ShowToggles(list, i);
            EditorGUILayout.EndHorizontal();
        }
    }
}

public static void ShowToggles (SerializedProperty list, int index)
{
    int r = 16;

    bool[ , ]nOff = new bool[r, r];

    for (int i = 0; i < 16; i++)
        {
            //Need to assign to itself, how to do it other than the way below?
            nOff[i, index] = EditorGUILayout.Toggle(nOff[i, index]);
            //Debug.Log (index);
        }

    }
}*</em>

*_ _*csharp
*using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor(typeof(BoolTester))]
public class BoolDrawer : Editor {

public override void OnInspectorGUI ()
{
    serializedObject.Update();
    EditorList.Show(serializedObject.FindProperty ("booleans"), EditorListOption.Toggles);
    serializedObject.ApplyModifiedProperties();

}

}
_
*_ _*csharp*_
*public class BoolTester : MonoBehaviour {

public bool[] booleans;

}
_
```*_
This really isn’t the glamorous part of programming so thank you so much for helping me ZG, your videos on youtube look immense, I got distracted for a while going ooooohhh Ahhhhhh, great work!!

The inspector/editor scripting is a bit of an odd duck. It takes a while figure out all the little things and the way it does things. I do a lot of editor tools (its about 25% of my job), and it still messes with my head from time to time. Typically, I find the best way to build tools is start as simple as absolutely possible to nail the functionality first, then abstract or break apart and then finally visual appearance. So, if I understand your goal, I would start with something like this:

// BoolTest.cs

using UnityEngine;
using System.Collections;

public class BoolTest : MonoBehaviour {
    [SerializeField] public int bool_row_length = 16;
    [SerializeField] public int bool_toggle_width = 12;
    [SerializeField] public bool[] boolList;
}

And then extend it with an editor like this:

// BoolTestEditor.cs
using UnityEngine;
using UnityEditor;
using System.Collections;

    [CustomEditor(typeof(BoolTest))]
    public class BoolTestEditor : Editor
    {
        private SerializedObject m_Obj;
       
        public void OnEnable()
        {
            m_Obj = new SerializedObject(target);
        }
       
       
        public override void OnInspectorGUI()
        {
            m_Obj.Update();
            int row_length = m_Obj.FindProperty("bool_row_length").intValue;
            int toggle_width = m_Obj.FindProperty("bool_toggle_width").intValue;
            SerializedProperty bool_list = m_Obj.FindProperty("boolList");
           
            EditorGUILayout.BeginVertical(); {
                EditorGUILayout.BeginHorizontal(); {
           
                if(bool_list.isArray)
                {
                    if(bool_list.arraySize>0)
                    {
                        int col_count = 0;
               
                        float block_width = (Screen.width-20)/(bool_list.arraySize+1);
                        for (int i = 0; i < bool_list.arraySize; i++)
                        {
                            SerializedProperty prop = bool_list.GetArrayElementAtIndex(i);
                            prop.boolValue = EditorGUILayout.Toggle(prop.boolValue, GUILayout.Width(toggle_width));
                            col_count++;
                   
                            if(col_count>row_length)
                            {
                                EditorGUILayout.EndHorizontal();
                                EditorGUILayout.BeginHorizontal();
                                col_count=0;
                            }
                        }
                    }
                    else
                    {
                            GUILayout.Label("Array of bools is empty");
                    }
                }
                } EditorGUILayout.EndHorizontal();
            } EditorGUILayout.EndVertical();


            m_Obj.ApplyModifiedProperties();
           
            // draw the raw inspector
            DrawDefaultInspector();
        }
    }

I did add some variables for spacing and lines, but otherwise it just reads and draws from the array of bools. Hopefully I understood what you are trying to accomplish. Let me know if you have any questions.

1 Like

Wow! Thank you for so much, it works perfectly! Trust me this inspector GUI scripting is not something I’m going to be diving back into anytime soon, this was bafflingly hard!

The thing I do notice in your script was the prop.boolValue and when I hover my cursor over it, it says {Get: Set:}
It seems to be the fundamental part that was confusing me so much…

SerializedProperty prop=bool_list.GetArrayElementAtIndex(i);

and then re-assigning it back to itself with prop.boolValue, I didn’t know boolValue even existed! I’m gonna have a hack and see if I can get it working in the other list one just for some peace/piece/pies of mind!

Here’s the finished looper with the bells and whistles:

using UnityEngine;
using System.Collections;
using System;

public class SamplerLoops : MonoBehaviour {

    public float bpm = 120;
    public float beatSegment = 16;
    private double nextEventTime;
    private bool running = false;

    public AudioClip[] loop1;
    public AudioClip[] loop2;
    public AudioClip[] loop3;
    public AudioClip[] loop4;

    [SerializeField] public bool[] booltests;
    [SerializeField] public int bool_row_length = 15;
    [SerializeField] public int bool_toggle_width = 28;

    private AudioSource[] audioSources = new AudioSource[4];
    private AudioHighPassFilter[] audioFilters = new AudioHighPassFilter[4];
    public int counter = 0;

    //public bool[] loops1 = new bool[16];
    [Range (0f,1.0f)]
    public float vol1 = 0.5f;
    [Range (20f,22000.0f)]
    public float cut1 = 20f;
    //public bool[] loops2 = new bool[16];
    [Range (0f,1.0f)]
    public float vol2 = 0.5f;
    [Range (20f,22000.0f)]
    public float cut2 = 20f;
    //public bool[] loops3 = new bool[16];
    [Range (0f,1.0f)]
    public float vol3 = 0.5f;
    [Range (20f,22000.0f)]
    public float cut3 = 20f;
    //public bool[] loops4 = new bool[16];
    [Range (0f,1.0f)]
    public float vol4 = 0.5f;
    [Range (20f,22000.0f)]
    public float cut4 = 20f;
    public int numNotes = 4;

    // Use this for initialization
    void Start () {
       
            GameObject looper1 = new GameObject ("Loop1");
            looper1.transform.parent = gameObject.transform;
            audioSources[0] = looper1.AddComponent<AudioSource> ();
            audioFilters[0] = looper1.AddComponent<AudioHighPassFilter> ();

            GameObject looper2 = new GameObject ("Loop2");
            looper2.transform.parent = gameObject.transform;
            audioSources[1] = looper2.AddComponent<AudioSource> ();
            audioFilters[1] = looper2.AddComponent<AudioHighPassFilter> ();

            GameObject looper3 = new GameObject ("Loop3");
            looper3.transform.parent = gameObject.transform;
            audioSources[2] = looper3.AddComponent<AudioSource> ();
            audioFilters[2] = looper3.AddComponent<AudioHighPassFilter> ();
           
            GameObject looper4 = new GameObject ("Loop4");
            looper4.transform.parent = gameObject.transform;
            audioSources[3] = looper4.AddComponent<AudioSource> ();
            audioFilters[3] = looper4.AddComponent<AudioHighPassFilter> ();
            nextEventTime = AudioSettings.dspTime + 2.0f;
            running = true;
    }
   
    // Update is called once per frame
    void Update () {
        if (!running)
            return;

        double time = AudioSettings.dspTime;
        if (time + 1.0f > nextEventTime)
        {
        //    audioSources.clip = kick[0];
        //    audioSources.PlayScheduled (nextEventTime);
        //    Debug.Log ("Scheduled source to start at time " + nextEventTime);
            Counter ();
            PlayStuff();
            nextEventTime += (60.0f / bpm) * beatSegment;
        }
        UpdateFX();
    }

    void Counter() {


        if (counter > numNotes) {
            counter = 0;
        } else {
            counter = counter + 1;
        }
    }
       
    void PlayStuff(){

        for (int i = 0; i < counter; i++)
        {
            if (booltests[counter-1] == true) {
                PlayLoop1 (0); // Zero here can take int variable to change the sound/loop being played
                    }
            if (booltests[counter+15] == true) {
                PlayLoop2(0);
            }

            if (booltests[counter+31] == true) {
                PlayLoop3(0);
            }

            if (booltests[counter+47] == true) {
                PlayLoop4(0);
            }
        }
    }

    void PlayLoop1 (int clip)

    {
        AudioSource audio1 = audioSources[0];
        audio1.clip = loop1[clip];
        audio1.Play ();
    }

    void PlayLoop2 (int clip)

    {
        AudioSource audio2 = audioSources[1];
        audio2.clip = loop2[clip];
        audio2.Play ();
    }

    void PlayLoop3 (int clip)

    {
        AudioSource audio3 = audioSources[2];
        audio3.clip = loop3[clip];
        audio3.Play ();
    }

    void PlayLoop4 (int clip)

    {
        AudioSource audio4 = audioSources[3];
        //audio4.loop = true;
        audio4.clip = loop4[clip];
        audio4.Play ();
    }

    void UpdateFX()
    {
        AudioSource audio1 = audioSources[0];
        audio1.volume = vol1;
        AudioHighPassFilter filter1 = audioFilters[0];
        filter1.cutoffFrequency = cut1;

        AudioSource audio2 = audioSources[1];
        AudioHighPassFilter filter2 = audioFilters[1];
        audio2.volume = vol2;
        filter2.cutoffFrequency = cut2;

        AudioSource audio3 = audioSources[2];
        AudioHighPassFilter filter3 = audioFilters[2];
        audio3.volume = vol3;
        filter3.cutoffFrequency = cut3;

        AudioSource audio4 = audioSources[3];
        AudioHighPassFilter filter4 = audioFilters[3];
        audio4.volume = vol4;
        filter4.cutoffFrequency = cut4;
    }
}

Here’s the script for the editor folder courtesy of ZombieGorrilla:

// StepLoopEditor.cs
using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor(typeof(SamplerLoops))]

public class StepLoopEditor : Editor
{
    private SerializedObject m_Obj;

    public void OnEnable()
    {
        m_Obj = new SerializedObject(target);
    }


    public override void OnInspectorGUI()
    {
        m_Obj.Update();


        int row_length = m_Obj.FindProperty("bool_row_length").intValue; // Find Length
        int toggle_width = m_Obj.FindProperty("bool_toggle_width").intValue; // Find Width
        SerializedProperty bool_list = m_Obj.FindProperty("booltests"); // Find the list

        EditorGUILayout.BeginVertical();

         {
            EditorGUILayout.BeginHorizontal(); {

                if(bool_list.isArray) // If it's an array
                {
                    if(bool_list.arraySize>0) // and array is greater than 0
                    {
                        int col_count = 0; // column count is 0

                        float block_width = (Screen.width-20)/(bool_list.arraySize+1);
                        for (int i = 0; i < bool_list.arraySize; i++) // For every item in the array do...
                        {
                            SerializedProperty prop = bool_list.GetArrayElementAtIndex(i); // find index
                            prop.boolValue = EditorGUILayout.Toggle(prop.boolValue, GUILayout.Width(toggle_width)); // Assign toggle
                            col_count++; //                                                                         // A bool value

                            if(col_count>row_length) // If column is greater than row
                            {
                                EditorGUILayout.EndHorizontal();
                                EditorGUILayout.BeginHorizontal();
                                col_count=0;
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Label("Array of bools is empty, set to multiple of 16");
                    }
                }
            } EditorGUILayout.EndHorizontal();
        } EditorGUILayout.EndVertical();


        m_Obj.ApplyModifiedProperties();

        // draw the raw inspector
        DrawDefaultInspector();
    }
}

and here’s the 16 step drum sequencer, still needs some work due to the last slot not playing the sound for some reason:

// Sampler16.cs
using UnityEngine;
using System.Collections;
using System;

public class StepSeq16 : MonoBehaviour
{
    public int counter = 0;
    public int numNotes = 15;
    [SerializeField] public bool[] booltests;
    [SerializeField] public int bool_row_length = 15;
    [SerializeField] public int bool_toggle_width = 28;

    public float bpm = 120;
    private double nextEventTime;
    private bool running = false;

    //public AudioClip[] clips = new AudioClip[2];
    public AudioClip[] kick;
    public AudioClip[] snare;
    public AudioClip[] hiHat;
    public AudioClip[] bassOneShot;
    AudioClip[] openHat;
    AudioClip[] chordOneShot;
    private AudioSource[] audioSources = new AudioSource[4];



    // Use this for initialization
    void Start () {
       
            GameObject child = new GameObject ("Player");
            child.transform.parent = gameObject.transform;
            audioSources[0] = child.AddComponent<AudioSource> ();
            audioSources[1] = child.AddComponent<AudioSource> ();
            audioSources[2] = child.AddComponent<AudioSource> ();
            audioSources[3] = child.AddComponent<AudioSource> ();
            nextEventTime = AudioSettings.dspTime + 2.0f;
            running = true;
    }
   
    // Update is called once per frame
    void Update () {
        if (!running)
            return;

        double time = AudioSettings.dspTime;
        if (time + 1.0f > nextEventTime)
        {
        //    audioSources.clip = kick[0];
        //    audioSources.PlayScheduled (nextEventTime);
        //    Debug.Log ("Scheduled source to start at time " + nextEventTime);
            nextEventTime += (60.0f / bpm) * 0.25;
            Counter ();
            PlayStuff();
        }
    }

    void Counter()
    {
        if (counter >= numNotes)
        {
            counter = 0;
        } else {
            counter += 1;
        }
    //    Debug.Log (counter);
    }

    void PlayStuff()
    {

        for (int i = 0; i < counter; i++)
        {
            if (booltests[counter-1] == true) {
                PlayKick (0);
                    }
            if (booltests[counter+15] == true) {
                PlaySnare (0);
            }
            if (booltests[counter+31] == true) {
                PlayHiHat (0);
            }
            if (booltests[counter+47] == true) {
                PlayBass (0);
            }
        }
    }

    void PlayKick (int clip)

    {
        AudioSource audio1 = audioSources[0];
        audio1.clip = kick[clip];
        audio1.Play ();
    }

    void PlaySnare (int clip)

    {
        AudioSource audio2 = audioSources[1];
        audio2.clip = snare[clip];
        audio2.Play ();
    }

    void PlayHiHat (int clip)

    {
        AudioSource audio3 = audioSources[2];
        audio3.clip = hiHat[clip];
        audio3.Play ();
    }

    void PlayBass (int clip)

    {
        AudioSource audio4 = audioSources[3];
        audio4.clip = bassOneShot[clip];
        audio4.Play ();
    }
       
}

And the editor script to go along with it:

// BoolTestEditor.cs
using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor(typeof(StepSeq16))]

public class BoolTestEditor : Editor
{
    private SerializedObject m_Obj;

    public void OnEnable()
    {
        m_Obj = new SerializedObject(target);
    }


    public override void OnInspectorGUI()
    {
        m_Obj.Update();


        int row_length = m_Obj.FindProperty("bool_row_length").intValue; // Find Length
        int toggle_width = m_Obj.FindProperty("bool_toggle_width").intValue; // Find Width
        SerializedProperty bool_list = m_Obj.FindProperty("booltests"); // Find the list

        EditorGUILayout.BeginVertical();

         {
            EditorGUILayout.BeginHorizontal(); {

                if(bool_list.isArray) // If it's an array
                {
                    if(bool_list.arraySize>0) // and array is greater than 0
                    {
                        int col_count = 0; // column count is 0

                        float block_width = (Screen.width-20)/(bool_list.arraySize+1);
                        for (int i = 0; i < bool_list.arraySize; i++) // For every item in the array do...
                        {
                            SerializedProperty prop = bool_list.GetArrayElementAtIndex(i); // find index
                            prop.boolValue = EditorGUILayout.Toggle(prop.boolValue, GUILayout.Width(toggle_width)); // Assign toggle
                            col_count++; //                                                                         // A bool value

                            if(col_count>row_length) // If column is greater than row
                            {
                                EditorGUILayout.EndHorizontal();
                                EditorGUILayout.BeginHorizontal();
                                col_count=0;
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Label("Array of bools is empty");
                    }
                }
            } EditorGUILayout.EndHorizontal();
        } EditorGUILayout.EndVertical();


        m_Obj.ApplyModifiedProperties();

        // draw the raw inspector
        DrawDefaultInspector();
    }
}

@zombiegorilla You are a legend thank you so so much! I can finally rest at ease!!

Glad to help! Like I said, the editor stuff can be a bit odd to deal with, if I can help someone avoid the head bashing I experienced with it, I am happy to do so. :wink: