void OnChange(SteamVR_Action_In action) //Creates and deploys an Event on any Input action
        {
            STKEventSender sender = GetComponent <STKEventSender>();

            sender.SetEventValue("Name", action.GetShortName());
            if (action.GetType() == typeof(SteamVR_Action_Boolean))
            {
                SteamVR_Action_Boolean v = (SteamVR_Action_Boolean)action;
                sender.SetEventValue("boolValue", v.GetState(SteamVR_Input_Sources.Any));
            }
            else if (action.GetType() == typeof(SteamVR_Action_Single))
            {
                SteamVR_Action_Single v = (SteamVR_Action_Single)action;
                sender.SetEventValue("singleValue", v.GetAxis(SteamVR_Input_Sources.Any));
            }
            else if (action.GetType() == typeof(SteamVR_Action_Vector2))
            {
                SteamVR_Action_Vector2 v = (SteamVR_Action_Vector2)action;
                sender.SetEventValue("vector2Value", v.GetAxis(SteamVR_Input_Sources.Any));
            }
            else if (action.GetType() == typeof(SteamVR_Action_Vector3))
            {
                SteamVR_Action_Vector3 v = (SteamVR_Action_Vector3)action;
                sender.SetEventValue("vector3Value", v.GetAxis(SteamVR_Input_Sources.Any));
            }
            sender.Deploy();
        }
        private void CreateEvent()
        {
            //Create Event itself
            STKEvent newEvent = (STKEvent)ScriptableObject.CreateInstance("STKEvent");

            newEvent.eventName = trackedObject.gameObject.name + trackedObject.gameObject.GetInstanceID().ToString();

            int           numberOfProperties = 0;
            int           numberOfFields     = 0;
            List <string> savedNames         = new List <string>();

            for (int i = 0; i < trackedObject.GetComponents(typeof(Component)).Length; i++)
            {
                Component c = trackedObject.GetComponents(typeof(Component))[i];

                //Cycle through variables
                if (trackedComponents[i] == true)
                {
                    for (int j = 0; j < c.GetType().GetProperties().Length; j++)
                    {
                        if (trackedVariables[i][j])
                        {
                            savedNames.Add(string.Join("", new string[] { c.GetType().GetProperties()[j].Name, "_", c.GetType().Name }));
                            numberOfProperties++;
                        }
                    }

                    for (int j = c.GetType().GetProperties().Length; j < c.GetType().GetFields().Length + c.GetType().GetProperties().Length; j++)
                    {
                        if (trackedVariables[i][j])
                        {
                            savedNames.Add(string.Join("", new string[] { c.GetType().GetFields()[j - c.GetType().GetProperties().Length].Name, "_", c.GetType().Name }));
                            numberOfFields++;
                        }
                    }
                }
            }

            try
            {
                STKTrackedObjects g = GameObject.Find("STKTrackedObjects").GetComponent <STKTrackedObjects>();
                Undo.RegisterCompleteObjectUndo(g, "Added to tracked objects");
                Undo.FlushUndoRecordObjects();
                g.trackedObjects.Add(trackedObject);
                EditorUtility.SetDirty(g);
            }
            catch (NullReferenceException e)
            {
                Debug.LogError("The STKTrackedObjects GameObject was not found in the scene. Please add it to the scene from the prefabs folder.");
            }

            //Attach Eventsender
            STKEventSender s = trackedObject.AddComponent <STKEventSender>();

            s.eventBase = newEvent;
            s.SetTrackedVar(trackedComponents, trackedVariables, savedNames);
            AssetDatabase.CreateAsset(newEvent, "Assets/VRScientificToolkit/Events/Track" + trackedObject.gameObject.name + trackedObject.gameObject.GetInstanceID().ToString() + ".asset");
            Undo.RecordObject(newEvent, "Created Event");
            AssetDatabase.Refresh();
            s.eventBase = (STKEvent)AssetDatabase.LoadAssetAtPath("Assets/VRScientificToolkit/Events/Track" + trackedObject.gameObject.name + trackedObject.gameObject.GetInstanceID().ToString() + ".asset", typeof(STKEvent));
            AssetDatabase.SaveAssets();
        }