/// <summary>
        /// Only called when first constructed.
        /// </summary>
        /// <param name="behaviourAI"></param>
        /// <param name="newJsonFilepath"></param>
        public void Initialize(OhBehaveAI behaviourAI, string jsonFilepath)
        {
            if (!AssetDatabase.IsValidFolder(blueprintsPath))
            {
                string guid = AssetDatabase.CreateFolder(
                    Path.GetDirectoryName(blueprintsPath),
                    Path.GetFileName(blueprintsPath));
                blueprintsPath = AssetDatabase.GUIDToAssetPath(guid);
            }


            AssetDatabase.CreateAsset(this,
                                      blueprintsPath + "/" + blueprintsPrefix
                                      + Path.GetFileNameWithoutExtension(jsonFilepath)
                                      + GetInstanceID() + ".asset");


            string blueprintGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(this));


            ohBehaveAI      = behaviourAI;
            behaviourSource = ohBehaveAI.GetComponent <OhBehaveActions>();


            savedNodes = new List <NodeEditorObject>();


            jsonTreeData               = new JsonBehaviourTree();
            jsonTreeData.name          = Path.GetFileNameWithoutExtension(jsonFilepath);
            jsonTreeData.blueprintGUID = blueprintGUID;
            string jsonString = JsonUtility.ToJson(jsonTreeData, true);

            StreamWriter writer = new StreamWriter(jsonFilepath);

            writer.WriteLine(jsonString);
            writer.Close();
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            string relativePath = jsonFilepath.Replace("Assets/StreamingAssets", "");

            ohBehaveAI.jsonFilepath = relativePath;
            jsonGUID = AssetDatabase.AssetPathToGUID(jsonFilepath);

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            EditorUtility.SetDirty(this);
        }
        public void GetFunctions()
        {
            if (behaviourSource == null)
            {
                if (ohBehaveAI != null)
                {
                    behaviourSource = ohBehaveAI.GetComponent <OhBehaveActions>();
                }
                else
                {
                    sharedMethods      = null;
                    privateMethods     = null;
                    sharedMethodNames  = null;
                    privateMethodNames = null;
                    return;
                }
            }


            sharedMethods      = new List <MethodInfo>();
            privateMethods     = new List <MethodInfo>();
            sharedMethodNames  = new List <string>();
            privateMethodNames = new List <string>();

            foreach (MethodInfo element in behaviourSource.GetType().GetMethods(flags))
            {
                foreach (var param in element.GetParameters())
                {
                    if (param.ParameterType == typeof(LeafNode))
                    {                     // at least one of the params must be a LeafNode
                        privateMethods.Add(element);
                        privateMethodNames.Add(element.Name);
                        break;
                    }
                }
            }

            sharedMethods.Add(null);
            sharedMethods.AddRange(privateMethods);
            sharedMethodNames.Add("No action selected");
            sharedMethodNames.AddRange(privateMethodNames);
        }