Exemple #1
0
 // Set the SysID
 public void SetSysID()
 {
     // Get the interpreter
     interpreter = GameObject.FindGameObjectWithTag("SceneInterpreter").GetComponent<SceneInterpreter>();
     // Set it to zero if we can't find ourselves
     if (interpreter != null && interpreter.EventObjects.Contains(gameObject))
     { SysID = 1 + interpreter.EventObjects.FindIndex((t) => { return (t == gameObject); }); }
     else { SysID = 0; }
 }
Exemple #2
0
    // Update is called once per frame
    public void UpdateEvent()
    {
        // Get the interpreter if it's null
        if (interpreter == null)
        {
            if (GameObject.FindGameObjectWithTag("SceneInterpreter"))
            {
                return;
            }
            interpreter = GameObject.FindGameObjectWithTag("SceneInterpreter").GetComponent <SceneInterpreter>();
        }
        // Return if the interpreter is running
        if (interpreter.InterpreterActive())
        {
            return;
        }

        // Check our pages and process if appropriate
        int pid          = pages.Count;
        int previousPage = currentPage;

        currentPage = -1;
        for (int i = pid - 1; i >= 0; i--)
        {
            // Check each criteria, if they all pass, this is the current page
            bool c1 = pages[i].variable1Name == "" || pages[i].variable1Value <= interpreter.GetVariable(pages[i].variable1Name);
            bool c2 = pages[i].variable2Name == "" || pages[i].variable2Value <= interpreter.GetVariable(pages[i].variable2Name);
            bool c3 = pages[i].switch1Name == "" || pages[i].switch1Value == interpreter.GetSwitch(pages[i].switch1Name);
            bool c4 = pages[i].switch2Name == "" || pages[i].switch2Value == interpreter.GetSwitch(pages[i].switch2Name);
            // If all 4 criteria match, that's our page
            if (c1 && c2 && c3 && c4)
            {
                if (previousPage != i)
                {
                    thisPageRun = false;
                }
                currentPage = i;
                break;
            }
        }

        // If our page trigger is auto and we're not running, run us!
        if (currentPage >= 0 && pages[currentPage].trigger == eEventTrigger.Auto && !thisPageRun)
        {
            Debug.Log(pages[currentPage].pageName + ": " + currentPage);
            // Add each event to the scene interpreter
            foreach (d_Event e in pages[currentPage].events)
            {
                interpreter.AddEvent(e, gameObject);
            }
            thisPageRun = true;
        }
    }
Exemple #3
0
 // Set the SysID
 public void SetSysID()
 {
     // Get the interpreter
     interpreter = GameObject.FindGameObjectWithTag("SceneInterpreter").GetComponent <SceneInterpreter>();
     // Set it to zero if we can't find ourselves
     if (interpreter != null && interpreter.EventObjects.Contains(gameObject))
     {
         SysID = 1 + interpreter.EventObjects.FindIndex((t) => { return(t == gameObject); });
     }
     else
     {
         SysID = 0;
     }
 }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        // Set our interprefer if it's not
        if (interpreter == null && GameObject.FindGameObjectWithTag("SceneInterpreter"))
        { interpreter = GameObject.FindGameObjectWithTag("SceneInterpreter").GetComponent<SceneInterpreter>(); }

        // Update the Camera
        UpdateCamera();

        // Update Players
        UpdatePlayers();

        // Update Inputs
        UpdateInput();
    }
Exemple #5
0
    // Update is called once per frame
    void Update()
    {
        // Set our interprefer if it's not
        if (interpreter == null && GameObject.FindGameObjectWithTag("SceneInterpreter"))
        {
            interpreter = GameObject.FindGameObjectWithTag("SceneInterpreter").GetComponent <SceneInterpreter>();
        }

        // Update the Camera
        UpdateCamera();

        // Update Players
        UpdatePlayers();

        // Update Inputs
        UpdateInput();
    }
Exemple #6
0
    // Update is called once per frame
    public void UpdateEvent()
    {
        // Get the interpreter if it's null
        if (interpreter == null)
        {
            if (GameObject.FindGameObjectWithTag("SceneInterpreter")) { return; }
            interpreter = GameObject.FindGameObjectWithTag("SceneInterpreter").GetComponent<SceneInterpreter>();
        }
        // Return if the interpreter is running
        if (interpreter.InterpreterActive()) { return; }

        // Check our pages and process if appropriate
        int pid = pages.Count;
        int previousPage = currentPage;
        currentPage = -1;
        for (int i = pid-1; i >= 0; i--)
        {
            // Check each criteria, if they all pass, this is the current page
            bool c1 = pages[i].variable1Name == "" || pages[i].variable1Value <= interpreter.GetVariable(pages[i].variable1Name);
            bool c2 = pages[i].variable2Name == "" || pages[i].variable2Value <= interpreter.GetVariable(pages[i].variable2Name);
            bool c3 = pages[i].switch1Name == "" || pages[i].switch1Value == interpreter.GetSwitch(pages[i].switch1Name);
            bool c4 = pages[i].switch2Name == "" || pages[i].switch2Value == interpreter.GetSwitch(pages[i].switch2Name);
            // If all 4 criteria match, that's our page
            if (c1 && c2 && c3 && c4)
            {
                if (previousPage != i) { thisPageRun = false; }
                currentPage = i;
                break;
            }
        }

        // If our page trigger is auto and we're not running, run us!
        if (currentPage >= 0 && pages[currentPage].trigger == eEventTrigger.Auto && !thisPageRun)
        {
            Debug.Log (pages[currentPage].pageName + ": " + currentPage);
            // Add each event to the scene interpreter
            foreach (d_Event e in pages[currentPage].events)
            { interpreter.AddEvent(e, gameObject); }
            thisPageRun = true;
        }
    }
Exemple #7
0
    void OnGUI()
    {
        // Do our basic checks to return if any fail
        if (Selection.activeGameObject == null)
        {
            return;
        }

        // Object Selected in the editor
        GameObject selected = Selection.activeGameObject;

        // Get the scene interpreter and database
        interpreter = GameObject.FindGameObjectWithTag("SceneInterpreter").GetComponent <SceneInterpreter>();

        // Event controller and Helper
        EventController eCont;
        EventHelper     eHelp;

        // Reset our changed state
        GUI.changed = false;

        // Check if we have a created event, if not and it's a valid object
        if (interpreter == null)
        {
            GUILayout.Label("Missing the SceneInterpreter"); return;
        }
        else if (selected == null)
        {
            GUILayout.Label("No GameObject is Selected"); return;
        }
        else if (selected.GetComponent <EventController>() != null)
        {
            // Get the EventController
            eCont = selected.GetComponent <EventController>();
            eHelp = selected.GetComponent <EventHelper>();

            // Show if we've created an event for this yet
            if (eCont.GetSysID() <= 0)
            {
                GUILayout.Label("This event hasn't been created yet", EditorStyles.boldLabel);
                if (GUILayout.Button("Click here to Create the Event"))
                {
                    // Add it to the SceneInterpreter
                    interpreter.EventObjects.Add(selected);
                }
                if (GUILayout.Button("Click here to Refresh SysID"))
                {
                    eCont.GetSysID();
                }
            }
            else
            {
                // Display the Event System ID
                GUILayout.Label("Event System ID: " + eCont.GetSysID(), EditorStyles.boldLabel);

                // Set us up as a scroll area
                scrollView = EditorGUILayout.BeginScrollView(scrollView);

                for (int i = 0; i < eCont.pages.Count; i++)
                {
                    // Update the open setting on the page to whatever the foldout control
                    // is, which is updated by the player
                    eCont.pages[i].open = foldout[i];

                    // This is the vertical for each Page
                    EditorGUILayout.BeginVertical("Button");

                    // These are the 'closed' controls
                    EditorGUILayout.BeginHorizontal("TextArea");
                    foldout[i] = EditorGUILayout.Foldout(foldout[i], eCont.pages[i].pageNumber + ": " + eCont.pages[i].pageName);
                    GUILayout.Label("", GUILayout.Width(200f));
                    // Display the number of events on this object
                    if (eCont.pages[i].events == null)
                    {
                        GUILayout.Label("Events: None");
                        GUILayout.Label("Trigger: None");
                    }
                    else
                    {
                        GUILayout.Label("Events: " + eCont.pages[i].events.Count);
                        GUILayout.Label("Trigger: " + eCont.pages[i].trigger.ToString());
                    }
                    // Move Up Control
                    if (GUILayout.Button("Move Up"))
                    {
                        int curIndex = eCont.pages.IndexOf(eCont.pages[i]);
                        if (curIndex > 0)
                        {
                            d_EventPage curr = eCont.pages[curIndex];
                            eCont.pages.RemoveAt(curIndex);
                            eCont.pages.Insert(curIndex - 1, curr);
                            TriggerPageChanges(selected);
                        }
                    }
                    // Move Down Control
                    if (GUILayout.Button("Move Down"))
                    {
                        int curIndex = eCont.pages.IndexOf(eCont.pages[i]);
                        if (curIndex < eCont.pages.Count - 1)
                        {
                            d_EventPage curr = eCont.pages[curIndex];
                            eCont.pages.RemoveAt(curIndex);
                            eCont.pages.Insert(curIndex + 1, curr);
                            TriggerPageChanges(selected);
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    // These are all the 'open' controls
                    if (foldout[i])
                    {
                        // Page Name
                        EditorGUILayout.BeginHorizontal("Label");
                        GUILayout.Label("Trigger:", GUILayout.Width(70f));
                        eCont.pages[i].trigger = (eEventTrigger)EditorGUILayout.EnumPopup(eCont.pages[i].trigger, GUILayout.Width(120f));
                        GUILayout.Label("Page Name:", GUILayout.Width(70f));
                        eCont.pages[i].pageName = GUILayout.TextField(eCont.pages[i].pageName);
                        EditorGUILayout.EndHorizontal();
                        // Page Variable Triggers
                        // Var1
                        EditorGUILayout.BeginHorizontal("Label");
                        GUILayout.Label("Var1:", GUILayout.Width(30f));
                        eCont.pages[i].variable1Name  = GUILayout.TextField(eCont.pages[i].variable1Name, GUILayout.Width(140f));
                        eCont.pages[i].variable1Value = EditorGUILayout.FloatField(eCont.pages[i].variable1Value, GUILayout.Width(100f));
                        // Var2
                        GUILayout.Label("Var2:", GUILayout.Width(30f));
                        eCont.pages[i].variable2Name  = GUILayout.TextField(eCont.pages[i].variable2Name, GUILayout.Width(140f));
                        eCont.pages[i].variable2Value = EditorGUILayout.FloatField(eCont.pages[i].variable2Value, GUILayout.Width(100f));
                        EditorGUILayout.EndHorizontal();
                        // Page Switch Triggers
                        // Switch1
                        EditorGUILayout.BeginHorizontal("Label");
                        GUILayout.Label("Swt1:", GUILayout.Width(30f));
                        eCont.pages[i].switch1Name  = GUILayout.TextField(eCont.pages[i].switch1Name, GUILayout.Width(140f));
                        eCont.pages[i].switch1Value = GUILayout.Toggle(eCont.pages[i].switch1Value, "", GUILayout.Width(100f));
                        // Switch2
                        GUILayout.Label("Swt2:", GUILayout.Width(30f));
                        eCont.pages[i].switch2Name  = GUILayout.TextField(eCont.pages[i].switch2Name, GUILayout.Width(140f));
                        eCont.pages[i].switch2Value = GUILayout.Toggle(eCont.pages[i].switch2Value, "", GUILayout.Width(100f));
                        EditorGUILayout.EndHorizontal();

                        // Display the current "Events"
                        GUILayout.Space(5f);
                        EditorGUILayout.BeginVertical("Label");


                        // Loop through events on the page
                        GUILayout.Label("Events:");
                        int j = 0;
                        foreach (d_Event e in eCont.pages[i].events)
                        {
                            EditorGUILayout.BeginVertical("Label");
                            EditorGUILayout.BeginHorizontal("Box");
                            GUILayout.Label(j.ToString(), GUILayout.Width(10f));
                            // Show the controls and their current value based on it's type
                            e.eventTypeID = (eEventType)EditorGUILayout.EnumPopup(e.eventTypeID, GUILayout.Width(120f));
                            // Buttons to move the event up/down in the list
                            if (GUILayout.Button("Up", GUILayout.Width(40f)))
                            {
                                int curIndex = eCont.pages[i].events.IndexOf(e);
                                if (curIndex > 0)
                                {
                                    d_Event curr = eCont.pages[i].events[curIndex];
                                    eCont.pages[i].events.RemoveAt(curIndex);
                                    eCont.pages[i].events.Insert(curIndex - 1, curr);
                                    TriggerPageChanges(selected);
                                    break;
                                }
                            }
                            // Move Down Control
                            if (GUILayout.Button("Down", GUILayout.Width(40f)))
                            {
                                int curIndex = eCont.pages[i].events.IndexOf(e);
                                if (curIndex < eCont.pages[i].events.Count - 1)
                                {
                                    d_Event curr = eCont.pages[i].events[curIndex];
                                    eCont.pages[i].events.RemoveAt(curIndex);
                                    eCont.pages[i].events.Insert(curIndex + 1, curr);
                                    TriggerPageChanges(selected);
                                    break;
                                }
                            }
                            // Delete Event Control
                            GUILayout.Label("", GUILayout.Width(20f));
                            if (GUILayout.Button("X", GUILayout.Width(26f)))
                            {
                                eCont.pages[i].events.Remove(e);
                                TriggerPageChanges(selected);
                                break;
                            }

                            // Display the event-specific fields
                            EditorGUILayout.EndHorizontal();

                            DisplayEventControls(e);

                            // End our groupings
                            EditorGUILayout.EndVertical();
                            GUILayout.Space(5f);
                            j += 1;                             // increase our simple counter
                        }


                        EditorGUILayout.EndVertical();
                        GUILayout.Space(5f);

                        // Display the controls to add a new event
                        //EditorGUILayout.BeginHorizontal("TextField");
                        //GUILayout.Label("Add a new Event to this page:", GUILayout.Width(200f));
                        if (GUILayout.Button("Add New Event", GUILayout.Width(150f)))
                        {
                            // Add a new element to the list of pages
                            d_Event newEvent = ScriptableObject.CreateInstance <d_Event>();
                            eCont.pages[i].events.Add(newEvent);
                            TriggerPageChanges(selected);
                        }
                        //EditorGUILayout.EndHorizontal();

                        // Delete Page Control
                        EditorGUILayout.BeginHorizontal("Label");
                        GUILayout.Label("Be careful! A deleted page cannot be recovered!");
                        GUILayout.Label("");
                        if (GUILayout.Button("Delete Page"))
                        {
                            eCont.pages.Remove(eCont.pages[i]);
                            TriggerPageChanges(selected);
                        }
                        EditorGUILayout.EndHorizontal();
                    }

                    // This is th end of a single page
                    EditorGUILayout.EndVertical();
                    GUILayout.Space(10f);
                }

                // All the controls outside the pages are below

                // Button to add a new page
                if (GUILayout.Button("Add New Page"))
                {
                    // Add a new element to the list of pages
                    d_EventPage newPage = ScriptableObject.CreateInstance <d_EventPage>();
                    newPage.Init(eCont.getMaxPage() + 1, "");
                    eCont.setMaxPage(newPage.pageNumber);
                    eCont.pages.Add(newPage);
                    TriggerPageChanges(selected);
                }

                EditorGUILayout.EndScrollView();
            }
        }
        // Show it doesn't have an EventController and allow the user to add one
        else
        {
            GUILayout.Label("Object doesn't have an 'EventController'", EditorStyles.boldLabel);
            if (GUILayout.Button("Click here to Add the EventController"))
            {
                selected.AddComponent <EventController>();
                selected.AddComponent <EventHelper>();
            }
        }

        // If anything changed...
        if (GUI.changed)
        {
        }
    }
Exemple #8
0
        public void ThrowsOnInvalidName()
        {
            var interpreter = new SceneInterpreter();

            Assert.False(interpreter.CanInterpret("@&&", DefaultContext));
        }
Exemple #9
0
        public void FailsToIdentifyCandidate()
        {
            var interpreter = new SceneInterpreter();

            Assert.False(interpreter.CanInterpret("*test", DefaultContext));
        }
Exemple #10
0
        public void IdentifiesAtSymbolAsCandidate()
        {
            var interpreter = new SceneInterpreter();

            Assert.True(interpreter.CanInterpret("@test", DefaultContext));
        }
Exemple #11
0
    void OnGUI()
    {
        // Do our basic checks to return if any fail
        if (Selection.activeGameObject == null) { return; }

        // Object Selected in the editor
        GameObject selected = Selection.activeGameObject;

        // Get the scene interpreter and database
        interpreter = GameObject.FindGameObjectWithTag("SceneInterpreter").GetComponent<SceneInterpreter>();

        // Event controller and Helper
        EventController eCont;
        EventHelper eHelp;

        // Reset our changed state
        GUI.changed = false;

        // Check if we have a created event, if not and it's a valid object
        if (interpreter == null) { GUILayout.Label ("Missing the SceneInterpreter"); return; }
        else if (selected == null) { GUILayout.Label ("No GameObject is Selected"); return; }
        else if (selected.GetComponent<EventController>() != null)
        {
            // Get the EventController
            eCont = selected.GetComponent<EventController>();
            eHelp = selected.GetComponent<EventHelper>();

            // Show if we've created an event for this yet
            if (eCont.GetSysID() <= 0)
            {
                GUILayout.Label ("This event hasn't been created yet", EditorStyles.boldLabel);
                if (GUILayout.Button("Click here to Create the Event"))
                {
                    // Add it to the SceneInterpreter
                    interpreter.EventObjects.Add(selected);
                }
                if (GUILayout.Button("Click here to Refresh SysID"))
                { eCont.GetSysID(); }
            }
            else
            {
                // Display the Event System ID
                GUILayout.Label ("Event System ID: " + eCont.GetSysID(), EditorStyles.boldLabel);

                // Set us up as a scroll area
                scrollView = EditorGUILayout.BeginScrollView(scrollView);

                for (int i = 0; i < eCont.pages.Count; i++)
                {
                    // Update the open setting on the page to whatever the foldout control
                    // is, which is updated by the player
                    eCont.pages[i].open = foldout[i];

                    // This is the vertical for each Page
                    EditorGUILayout.BeginVertical("Button");

                    // These are the 'closed' controls
                    EditorGUILayout.BeginHorizontal("TextArea");
                    foldout[i] = EditorGUILayout.Foldout(foldout[i], eCont.pages[i].pageNumber + ": " + eCont.pages[i].pageName);
                    GUILayout.Label("", GUILayout.Width(200f));
                    // Display the number of events on this object
                    if (eCont.pages[i].events == null)
                    {
                        GUILayout.Label("Events: None");
                        GUILayout.Label("Trigger: None");
                    }
                    else
                    {
                        GUILayout.Label("Events: " + eCont.pages[i].events.Count);
                        GUILayout.Label("Trigger: " + eCont.pages[i].trigger.ToString());
                    }
                    // Move Up Control
                    if (GUILayout.Button("Move Up"))
                    {
                        int curIndex = eCont.pages.IndexOf(eCont.pages[i]);
                        if (curIndex > 0)
                        {
                            d_EventPage curr = eCont.pages[curIndex];
                            eCont.pages.RemoveAt(curIndex);
                            eCont.pages.Insert(curIndex-1, curr);
                            TriggerPageChanges(selected);
                        }
                    }
                    // Move Down Control
                    if (GUILayout.Button("Move Down"))
                    {
                        int curIndex = eCont.pages.IndexOf(eCont.pages[i]);
                        if (curIndex < eCont.pages.Count-1)
                        {
                            d_EventPage curr = eCont.pages[curIndex];
                            eCont.pages.RemoveAt(curIndex);
                            eCont.pages.Insert(curIndex+1, curr);
                            TriggerPageChanges(selected);
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    // These are all the 'open' controls
                    if (foldout[i])
                    {
                        // Page Name
                        EditorGUILayout.BeginHorizontal("Label");
                        GUILayout.Label("Trigger:", GUILayout.Width(70f));
                        eCont.pages[i].trigger = (eEventTrigger)EditorGUILayout.EnumPopup(eCont.pages[i].trigger, GUILayout.Width(120f));
                        GUILayout.Label("Page Name:", GUILayout.Width(70f));
                        eCont.pages[i].pageName = GUILayout.TextField(eCont.pages[i].pageName);
                        EditorGUILayout.EndHorizontal();
                        // Page Variable Triggers
                            // Var1
                        EditorGUILayout.BeginHorizontal("Label");
                        GUILayout.Label("Var1:",GUILayout.Width(30f));
                        eCont.pages[i].variable1Name = GUILayout.TextField(eCont.pages[i].variable1Name, GUILayout.Width(140f));
                        eCont.pages[i].variable1Value = EditorGUILayout.FloatField(eCont.pages[i].variable1Value, GUILayout.Width(100f));
                            // Var2
                        GUILayout.Label("Var2:", GUILayout.Width(30f));
                        eCont.pages[i].variable2Name = GUILayout.TextField(eCont.pages[i].variable2Name, GUILayout.Width(140f));
                        eCont.pages[i].variable2Value = EditorGUILayout.FloatField(eCont.pages[i].variable2Value, GUILayout.Width(100f));
                        EditorGUILayout.EndHorizontal();
                        // Page Switch Triggers
                            // Switch1
                        EditorGUILayout.BeginHorizontal("Label");
                        GUILayout.Label("Swt1:",GUILayout.Width(30f));
                        eCont.pages[i].switch1Name = GUILayout.TextField(eCont.pages[i].switch1Name, GUILayout.Width(140f));
                        eCont.pages[i].switch1Value = GUILayout.Toggle(eCont.pages[i].switch1Value, "", GUILayout.Width(100f));
                            // Switch2
                        GUILayout.Label("Swt2:", GUILayout.Width(30f));
                        eCont.pages[i].switch2Name = GUILayout.TextField(eCont.pages[i].switch2Name, GUILayout.Width(140f));
                        eCont.pages[i].switch2Value = GUILayout.Toggle(eCont.pages[i].switch2Value, "", GUILayout.Width(100f));
                        EditorGUILayout.EndHorizontal();

                        // Display the current "Events"
                        GUILayout.Space(5f);
                        EditorGUILayout.BeginVertical("Label");

                            // Loop through events on the page
                        GUILayout.Label("Events:");
                        int j = 0;
                        foreach (d_Event e in eCont.pages[i].events)
                        {
                            EditorGUILayout.BeginVertical("Label");
                            EditorGUILayout.BeginHorizontal("Box");
                            GUILayout.Label(j.ToString(), GUILayout.Width(10f));
                            // Show the controls and their current value based on it's type
                            e.eventTypeID = (eEventType)EditorGUILayout.EnumPopup(e.eventTypeID, GUILayout.Width(120f));
                            // Buttons to move the event up/down in the list
                            if (GUILayout.Button("Up", GUILayout.Width(40f)))
                            {
                                int curIndex = eCont.pages[i].events.IndexOf(e);
                                if (curIndex > 0)
                                {
                                    d_Event curr = eCont.pages[i].events[curIndex];
                                    eCont.pages[i].events.RemoveAt(curIndex);
                                    eCont.pages[i].events.Insert(curIndex-1, curr);
                                    TriggerPageChanges(selected);
                                    break;
                                }
                            }
                            // Move Down Control
                            if (GUILayout.Button("Down", GUILayout.Width(40f)))
                            {
                                int curIndex = eCont.pages[i].events.IndexOf(e);
                                if (curIndex < eCont.pages[i].events.Count-1)
                                {
                                    d_Event curr = eCont.pages[i].events[curIndex];
                                    eCont.pages[i].events.RemoveAt(curIndex);
                                    eCont.pages[i].events.Insert(curIndex+1, curr);
                                    TriggerPageChanges(selected);
                                    break;
                                }
                            }
                            // Delete Event Control
                            GUILayout.Label("", GUILayout.Width(20f));
                            if (GUILayout.Button("X", GUILayout.Width(26f)))
                            {
                                eCont.pages[i].events.Remove(e);
                                TriggerPageChanges(selected);
                                break;
                            }

                            // Display the event-specific fields
                            EditorGUILayout.EndHorizontal();

                            DisplayEventControls(e);

                            // End our groupings
                            EditorGUILayout.EndVertical();
                            GUILayout.Space(5f);
                            j += 1; // increase our simple counter
                        }

                        EditorGUILayout.EndVertical();
                        GUILayout.Space(5f);

                        // Display the controls to add a new event
                        //EditorGUILayout.BeginHorizontal("TextField");
                        //GUILayout.Label("Add a new Event to this page:", GUILayout.Width(200f));
                        if (GUILayout.Button("Add New Event", GUILayout.Width(150f)))
                        {
                            // Add a new element to the list of pages
                            d_Event newEvent = ScriptableObject.CreateInstance<d_Event>();
                            eCont.pages[i].events.Add(newEvent);
                            TriggerPageChanges(selected);
                        }
                        //EditorGUILayout.EndHorizontal();

                        // Delete Page Control
                        EditorGUILayout.BeginHorizontal("Label");
                        GUILayout.Label("Be careful! A deleted page cannot be recovered!");
                        GUILayout.Label("");
                        if (GUILayout.Button("Delete Page"))
                        {
                            eCont.pages.Remove(eCont.pages[i]);
                            TriggerPageChanges(selected);
                        }
                        EditorGUILayout.EndHorizontal();
                    }

                    // This is th end of a single page
                    EditorGUILayout.EndVertical();
                    GUILayout.Space(10f);
                }

                // All the controls outside the pages are below

                // Button to add a new page
                if (GUILayout.Button("Add New Page"))
                {
                    // Add a new element to the list of pages
                    d_EventPage newPage = ScriptableObject.CreateInstance<d_EventPage>();
                    newPage.Init(eCont.getMaxPage()+1, "");
                    eCont.setMaxPage(newPage.pageNumber);
                    eCont.pages.Add(newPage);
                    TriggerPageChanges(selected);
                }

                EditorGUILayout.EndScrollView();
            }
        }
        // Show it doesn't have an EventController and allow the user to add one
        else
        {
            GUILayout.Label ("Object doesn't have an 'EventController'", EditorStyles.boldLabel);
            if (GUILayout.Button("Click here to Add the EventController"))
            {
                selected.AddComponent<EventController>();
                selected.AddComponent<EventHelper>();
            }
        }

        // If anything changed...
        if (GUI.changed)
        { }
    }