public void SetInputContext(BehaviourTreeExecutionNode node)
 {
     foreach (System.Collections.Generic.KeyValuePair <string, string> record in node.contextLink)
     {
         if (record.Key.StartsWith("in_"))
         {
             try {
                 PropertyReader.SetValue(this, record.Key, this.agent.GetContext()[record.Value]);
             } catch (KeyNotFoundException e) {
                 Debug.LogError("The variable " + record.Value + " doesn't exist in this context.");
                 Debug.LogException(e);
             }
         }
     }
 }
    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();
    }