private void OnGUI()
        {
            if (trackedObject != null)
            {
                if (trackedObject != lastTrackedObject)
                {
                    trackedComponents = new bool[trackedObject.GetComponents(typeof(Component)).Length];
                    trackedVariables  = new bool[trackedObject.GetComponents(typeof(Component)).Length][];
                }
                EditorGUILayout.LabelField("Select the components and variables you want to track:");
                //Cycle through components of the tracked object
                for (int i = 0; i < trackedObject.GetComponents(typeof(Component)).Length; i++)
                {
                    Component c = trackedObject.GetComponents(typeof(Component))[i];
                    if (c != null)
                    {
                        EditorStyles.label.fontStyle = FontStyle.Bold;
                        trackedComponents[i]         = EditorGUILayout.Toggle(c.GetType().ToString(), trackedComponents[i]);
                        EditorStyles.label.fontStyle = FontStyle.Normal;
                        if (trackedObject != lastTrackedObject)
                        {
                            trackedVariables[i] = new bool[c.GetType().GetProperties().Length + c.GetType().GetFields().Length];
                        }
                    }

                    //Cycle through variables
                    if (trackedComponents[i] == true)
                    {
                        EditorGUI.indentLevel++;
                        for (int j = 0; j < c.GetType().GetProperties().Length; j++)
                        {
                            var varToCheck = c.GetType().GetProperties()[j];
                            if (STKEventTypeChecker.IsValid(varToCheck.PropertyType))
                            {
                                trackedVariables[i][j] = EditorGUILayout.Toggle(varToCheck.Name, trackedVariables[i][j]);
                            }
                        }

                        for (int j = c.GetType().GetProperties().Length; j < c.GetType().GetFields().Length + c.GetType().GetProperties().Length; j++)
                        {
                            var varToCheck = c.GetType().GetFields()[j - c.GetType().GetProperties().Length];
                            if (STKEventTypeChecker.IsValid(varToCheck.FieldType))
                            {
                                trackedVariables[i][j] = EditorGUILayout.Toggle(varToCheck.Name, trackedVariables[i][j]);
                            }
                        }
                        EditorGUI.indentLevel--;
                    }
                }
                if (GUILayout.Button("Create Tracker"))
                {
                    CreateEvent();
                    trackedObject = null;
                }
            }
            else
            {
                EditorGUILayout.LabelField("Please select a GameObject to track in the inspector.");
            }


            lastTrackedObject = trackedObject;
        }
        ///<summary>Sets references to the tracked variables of this Gameobject.</summary>
        public void SetTrackedVar(bool[] comps, bool[][] vars, List <string> eventVarNames)
        {
            int numberoftrackedComps = 0;

            foreach (bool c in comps)
            {
                if (c)
                {
                    numberoftrackedComps++;
                }
            }

            trackedComponents          = new Component[numberoftrackedComps];
            trackedVariableNames       = new DoubleStringArray();
            trackedVariableNames.array = new DoubleStringArray.StringArray[numberoftrackedComps];

            eventVariableNames       = new DoubleStringArray();
            eventVariableNames.array = new DoubleStringArray.StringArray[numberoftrackedComps];

            for (int i = 0; i < numberoftrackedComps; i++)
            {
                trackedVariableNames.array[i] = new DoubleStringArray.StringArray();
                eventVariableNames.array[i]   = new DoubleStringArray.StringArray();
            }

            int eventVariableIndex = 0;
            int trackedCompsIndex  = 0;

            for (int i = 0; i < comps.Length; i++)
            {
                if (comps[i])
                {
                    trackedComponents[trackedCompsIndex] = GetComponents(typeof(Component))[i];

                    int numberofTrackedVars = 0;
                    foreach (bool b in vars[i])
                    {
                        if (b)
                        {
                            numberofTrackedVars++;
                        }
                    }
                    trackedVariableNames.array[trackedCompsIndex].array = new string[numberofTrackedVars];
                    eventVariableNames.array[trackedCompsIndex].array   = new string[numberofTrackedVars];

                    int varNameIndex = 0;

                    for (int j = 0; j < vars[i].Length; j++)
                    {
                        if (vars[i][j])
                        {
                            if (j >= trackedComponents[trackedCompsIndex].GetType().GetProperties().Length)
                            {
                                trackedVariableNames.array[trackedCompsIndex].array[varNameIndex] = trackedComponents[trackedCompsIndex].GetType().GetFields()[j - trackedComponents[trackedCompsIndex].GetType().GetProperties().Length].Name;
                                eventVariableNames.array[trackedCompsIndex].array[varNameIndex]   = eventVarNames[eventVariableIndex];
                                eventBase.AddParameter(eventVarNames[eventVariableIndex], STKEventTypeChecker.getIndex(trackedComponents[trackedCompsIndex].GetType().GetField(trackedVariableNames.array[trackedCompsIndex].array[varNameIndex]).GetValue(trackedComponents[trackedCompsIndex]).GetType()));
                            }
                            else
                            {
                                trackedVariableNames.array[trackedCompsIndex].array[varNameIndex] = trackedComponents[trackedCompsIndex].GetType().GetProperties()[j].Name;
                                eventVariableNames.array[trackedCompsIndex].array[varNameIndex]   = eventVarNames[eventVariableIndex];
                                eventBase.AddParameter(eventVarNames[eventVariableIndex], STKEventTypeChecker.getIndex(trackedComponents[trackedCompsIndex].GetType().GetProperty(trackedVariableNames.array[trackedCompsIndex].array[varNameIndex]).GetValue(trackedComponents[trackedCompsIndex]).GetType()));
                            }
                            varNameIndex++;
                            eventVariableIndex++;
                        }
                    }

                    trackedCompsIndex++;
                }
            }
        }