public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        IndexedItemAttribute indexedItem = attribute as IndexedItemAttribute;

        if (coreData == null)
        {
            foreach (string guid in AssetDatabase.FindAssets("t: CoreData"))
            {
                coreData = AssetDatabase.LoadAssetAtPath <CoreData>(AssetDatabase.GUIDToAssetPath(guid));
            }
        }
        switch (indexedItem.type)
        {
        case IndexedItemAttribute.IndexedItemType.SCRIPTS:
            property.intValue = EditorGUI.IntPopup(position, property.intValue, coreData.GetScriptNames(), null);
            break;

        case IndexedItemAttribute.IndexedItemType.STATES:
            property.intValue = EditorGUI.IntPopup(position, property.intValue, coreData.GetStateNames(), null);
            break;
        }
    }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        //get the attricbut since it contains the range of the slider
        IndexedItemAttribute indexedItem = attribute as IndexedItemAttribute;

        if (coreData == null)
        {
            foreach (string guid in AssetDatabase.FindAssets("t: CoreData"))//looks at whole project for assets tagged CoreData
            {
                coreData = AssetDatabase.LoadAssetAtPath <CoreData>(AssetDatabase.GUIDToAssetPath(guid));
            }
        }

        switch (indexedItem.type)
        {
        case IndexedItemAttribute.IndexedItemType.SCRIPTS:
            property.intValue = EditorGUI.IntPopup(position, property.intValue, coreData.GetScriptNames(), null);
            break;

        case IndexedItemAttribute.IndexedItemType.STATES:
            property.intValue = EditorGUI.IntPopup(position, property.intValue, coreData.GetStateNames(), null);
            break;

        case IndexedItemAttribute.IndexedItemType.RAW_INPUTS:
            //property.intValue = EditorGUI.Popup(position, property.intValue, coreData.GetRawInputNames(), EditorStyles.miniButtonLeft);
            property.intValue = EditorGUI.IntPopup(position, property.intValue, coreData.GetRawInputNames(), null);
            break;

        case IndexedItemAttribute.IndexedItemType.CHAIN_COMMAND:
            //property.intValue = EditorGUI.IntPopup(position, property.intValue, coreData.GetChainCommandNames(), null);
            break;

        case IndexedItemAttribute.IndexedItemType.COMMAND_STATES:
            property.intValue = EditorGUI.IntPopup(position, property.intValue, coreData.GetCommandStateNames(), null);
            break;
        }
        //base.OnGUI(position, property, label);
    }
    void WindowFunction(int windowID)
    {
        MoveList     currentMoveList           = coreData.moveLists[coreData.currentMovelistIndex];
        CommandState currentCommandStateObject = currentMoveList.commandStates[currentCommandStateIndex];

        if (currentCommandStateIndex >= currentMoveList.commandStates.Count)
        {
            currentCommandStateIndex = 0;
        }
        if (windowID >= currentCommandStateObject.commandSteps.Count)
        {
            return;
        }
        currentCommandStateObject.commandSteps[windowID].myRect.width  = 175;
        currentCommandStateObject.commandSteps[windowID].myRect.height = 50;


        EditorGUI.LabelField(new Rect(6, 7, 35, 20), windowID.ToString());
        currentCommandStateObject.commandSteps[windowID].command.motionCommand =
            EditorGUI.IntPopup(new Rect(25, 5, 50, 20), currentCommandStateObject.commandSteps[windowID].command.motionCommand, coreData.GetMotionCommandNames(), null, EditorStyles.miniButtonLeft);

        currentCommandStateObject.commandSteps[windowID].command.input =
            EditorGUI.IntPopup(new Rect(75, 5, 65, 20), currentCommandStateObject.commandSteps[windowID].command.input, coreData.GetRawInputNames(), null, EditorStyles.miniButtonMid);
        currentCommandStateObject.commandSteps[windowID].command.state =
            EditorGUI.IntPopup(new Rect(40, 26, 70, 20), currentCommandStateObject.commandSteps[windowID].command.state, coreData.GetStateNames(), null, EditorStyles.miniButton);

        currentCommandStateObject.commandSteps[windowID].priority =
            EditorGUI.IntField(new Rect(6, 26, 20, 20), currentCommandStateObject.commandSteps[windowID].priority);


        int nextFollowup = -1;

        nextFollowup = EditorGUI.IntPopup(new Rect(150, 15, 21, 20), nextFollowup, coreData.GetFollowUpNames(currentCommandStateIndex, true), null, EditorStyles.miniButton);

        if (nextFollowup != -1)
        {
            if (currentCommandStateObject.commandSteps.Count > 0)
            {
                if (nextFollowup >= currentCommandStateObject.commandSteps.Count + 1)
                {
                    currentCommandStateObject.RemoveChainCommands(windowID);
                }
                else if (nextFollowup >= currentCommandStateObject.commandSteps.Count)
                {
                    CommandStep nextCommand = currentCommandStateObject.AddCommandStep();
                    nextCommand.myRect.x      = currentCommandStateObject.commandSteps[windowID].myRect.xMax + 40f;
                    nextCommand.myRect.y      = currentCommandStateObject.commandSteps[windowID].myRect.center.y - 15f;
                    nextCommand.command.input = currentCommandStateObject.commandSteps[windowID].command.input;
                    nextCommand.command.state = currentCommandStateObject.commandSteps[windowID].command.state;

                    currentCommandStateObject.commandSteps[windowID].AddFollowUp(nextCommand.idIndex);
                }
                else
                {
                    currentCommandStateObject.commandSteps[windowID].AddFollowUp(nextFollowup);
                }
            }
            else
            {
                currentCommandStateObject.commandSteps[windowID].AddFollowUp(nextFollowup);
            }
            currentCommandStateObject.CleanUpBaseState();
        }

        if ((Event.current.button == 0) && (Event.current.type == EventType.MouseDown))
        {
            currentChainStep = windowID;
        }

        GUI.DragWindow();
    }
    private void OnGUI()
    {
        if (coreData == null)
        {
            foreach (string guid in AssetDatabase.FindAssets("t: CoreData"))
            {
                coreData = AssetDatabase.LoadAssetAtPath <CoreData>(AssetDatabase.GUIDToAssetPath(guid));
            }
        }
        scrollView = GUILayout.BeginScrollView(scrollView);
        //currentStateIndex = 0; //use in case of nre
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label(currentStateIndex.ToString() + " | " + currentCharacterState.stateName, GUILayout.Width(200));
        currentStateIndex = EditorGUILayout.Popup(currentStateIndex, coreData.GetStateNames());
        if (GUILayout.Button("New Character State"))
        {
            coreData.characterStates.Add(new CharacterState());
            currentStateIndex = coreData.characterStates.Count - 1;
        }
        currentCharacterState = coreData.characterStates[currentStateIndex];



        EditorGUILayout.EndHorizontal();

        currentCharacterState.stateName = EditorGUILayout.TextField("State Name : ", currentCharacterState.stateName, GUILayout.Width(500));
        //Animation
        EditorGUILayout.BeginHorizontal();
        currentCharacterState.length    = EditorGUILayout.FloatField("Length : ", currentCharacterState.length);
        currentCharacterState.blendRate = EditorGUILayout.FloatField("BlendRate : ", currentCharacterState.blendRate);
        currentCharacterState.loop      = GUILayout.Toggle(currentCharacterState.loop, "Loop? ", EditorStyles.miniButton);
        EditorGUILayout.EndHorizontal();
        //Flags
        currentCharacterState.groundedReq = GUILayout.Toggle(currentCharacterState.groundedReq, "Grounded? ", EditorStyles.miniButton, GUILayout.Width(75));
        currentCharacterState.wallReq     = GUILayout.Toggle(currentCharacterState.wallReq, "Wall? ", EditorStyles.miniButton, GUILayout.Width(75));

        //Events
        GUILayout.Label("");
        //GUILayout.Label("Events");
        eventFold = EditorGUILayout.Foldout(eventFold, "Events");
        if (eventFold)
        {
            int deleteEvent = -1;

            //if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(35))){ currentCharacterState.events.Add(new StateEvent()); }

            for (int e = 0; e < currentCharacterState.events.Count; e++)
            {
                StateEvent currentEvent = currentCharacterState.events[e];
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("x", EditorStyles.miniButton, GUILayout.Width(25)))
                {
                    deleteEvent = e;
                }
                currentEvent.active = EditorGUILayout.Toggle(currentEvent.active = true, GUILayout.Width(20));
                GUILayout.Label(e.ToString() + " : ", GUILayout.Width(25));
                EditorGUILayout.MinMaxSlider(ref currentEvent.start, ref currentEvent.end, 0f, currentCharacterState.length, GUILayout.Width(400));
                GUILayout.Label(Mathf.Round(currentEvent.start).ToString() + " ~ " + Mathf.Round(currentEvent.end).ToString(), GUILayout.Width(75));
                currentEvent.script = EditorGUILayout.Popup(currentEvent.script, coreData.GetScriptNames());
                GUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();

                if (currentEvent.parameters.Count != coreData.characterScripts[currentEvent.script].parameters.Count)
                {
                    currentEvent.parameters = new List <ScriptParameters>();
                    for (int i = 0; i < coreData.characterScripts[currentEvent.script].parameters.Count; i++)
                    {
                        currentEvent.parameters.Add(new ScriptParameters());
                    }
                }
                for (int p = 0; p < currentEvent.parameters.Count; p++)
                {
                    if (p % 3 == 0)
                    {
                        GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("", GUILayout.Width(250));
                    }

                    GUILayout.Label(coreData.characterScripts[currentEvent.script].parameters[p].name + " : ", GUILayout.Width(85));
                    currentEvent.parameters[p].val = EditorGUILayout.FloatField(currentEvent.parameters[p].val, GUILayout.Width(75));
                }
                EditorGUILayout.EndHorizontal();
                GUILayout.Label("");
            }
            if (deleteEvent > -1)
            {
                currentCharacterState.events.RemoveAt(deleteEvent);
            }
            if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(35)))
            {
                currentCharacterState.events.Add(new StateEvent());
            }
            GUILayout.Label("");
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.EndHorizontal();

        GUILayout.EndScrollView();
        EditorUtility.SetDirty(coreData);
    }