void AddContextField(BehaviourTreeExecutionNode node, PropertyReader.Variable variable)
    {
        GUILayout.BeginHorizontal();

        try {
            if (!node.contextLink.ContainsKey(variable.name))
            {
                node.contextLink[variable.name] = variable.name.Split('_')[1];
            }
            string initialValue = node.contextLink[variable.name];

            GUI.color = Color.black;
            GUILayout.Label(variable.name.Split('_')[1], GUI.skin.label);

            GUI.color = Color.white;
            string value = EditorGUILayout.TextField(initialValue);

            node.contextLink[variable.name] = value;

            if (value != initialValue)
            {
                BehaviourTreeEditorWindow.SaveNodeAnChildren(node);
            }
        } catch (KeyNotFoundException e) {
            Debug.LogError("the key " + variable.name + " is not in the task context link array.");
            Debug.LogException(e);
        }


        GUILayout.EndHorizontal();
    }
    void AddParameterField(BehaviourTreeExecutionNode node, PropertyReader.Variable variable)
    {
        GUILayout.BeginHorizontal();

        object initialValue = PropertyReader.GetValue(node.task, variable.name);

        GUI.color = Color.black;
        GUILayout.Label(variable.name.Split('_')[1], GUI.skin.label);

        GUI.color = Color.white;

        object value = null;

        if (variable.type == typeof(string))
        {
            value = EditorGUILayout.TextField((string)initialValue);
        }
        else if (variable.type == typeof(float))
        {
            value = EditorGUILayout.FloatField((float)initialValue);
        }
        else if (variable.type == typeof(int))
        {
            value = EditorGUILayout.IntField((int)initialValue);
        }
        else if (variable.type == typeof(double))
        {
            value = EditorGUILayout.DoubleField((double)initialValue);
        }
        else if (variable.type == typeof(bool))
        {
            value = EditorGUILayout.Toggle((bool)initialValue);
        }

        if (value == null)
        {
            GUILayout.EndHorizontal();
            return;
        }

        if (value != initialValue)
        {
            SerializedObject taskSerializedAsset = new SerializedObject(node.task);

            taskSerializedAsset.Update();

            PropertyReader.SetValue(node.task, variable.name, value);

            SerializedProperty p = taskSerializedAsset.FindProperty(variable.name);

            if (value is string)
            {
                p.stringValue = (string)value;
            }
            else if (value is float)
            {
                p.floatValue = (float)value;
            }
            else if (value is int)
            {
                p.intValue = (int)value;
            }
            else if (value is double)
            {
                p.doubleValue = (double)value;
            }
            else if (value is bool)
            {
                p.boolValue = (bool)value;
            }

            taskSerializedAsset.ApplyModifiedProperties();

            BehaviourTreeEditorWindow.SaveNodeAnChildren(node);
        }

        GUILayout.EndHorizontal();
    }