Ejemplo n.º 1
0
 public void Reset()
 {
     CurNode       = null;
     _isDrag       = false;
     _curAssets    = new NodeAssets();
     _isConnecting = false;
     _nodeList     = new List <NodeBase>();
     _lineList.Clear();
     CreateNode("根节点", typeof(SelectorNode), _window.GetXYCount(_window.position.center), NodeGUIStyle.RootNormalStyle, NodeGUIStyle.RootSelectedStyle);
     _window.Repaint();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 加载资源
 /// </summary>
 /// <param name="nodeAssets"></param>
 public void LoadAssets(NodeAssets nodeAssets)
 {
     if (nodeAssets == null)
     {
         string path = EditorUtility.OpenFilePanel("Load", "Assets/Resources/BehaviourTreeAssets", "asset");
         path = path.Replace(Application.dataPath, "Assets");
         if (string.IsNullOrEmpty(path))
         {
             return;
         }
         nodeAssets = AssetDatabase.LoadAssetAtPath(path, typeof(NodeAssets)) as NodeAssets;
     }
     if (nodeAssets != null)
     {
         _nodeEditor.Refresh(nodeAssets);
     }
 }
Ejemplo n.º 3
0
 public void Refresh(NodeAssets assets)
 {
     if (_curAssets == assets)
     {
         return;
     }
     _curAssets = assets;
     _nodeList  = new List <NodeBase>(assets.NodesList);
     for (int i = 0; i < _nodeList.Count; i++)
     {
         _nodeList[i].Reset();
     }
     for (int i = 0; i < _nodeList.Count; i++)
     {
         _nodeList[i].Reload(ReloadLine);
     }
     //_nodeList[0].Reload(ReloadLine);
     _window.Repaint();
 }
Ejemplo n.º 4
0
    /// <summary>
    /// 另存为资源
    /// </summary>
    public void SaveNewNodeAssets()
    {
        NodeAssets assets = ScriptableObject.CreateInstance(typeof(NodeAssets)) as NodeAssets;

        assets.RootNode = _nodeList[0];
        //_curAssets = assets;
        string assetsPath = EditorUtility.SaveFilePanelInProject("Save", "new BehaviourTree", "asset", "", "Assets/Resources/BehaviourTreeAssets");

        if (string.IsNullOrEmpty(assetsPath))
        {
            return;
        }
        AssetDatabase.CreateAsset(assets, assetsPath);
        for (int i = 0; i < _nodeList.Count; i++)
        {
            if (!assets.NodesList.Contains(_nodeList[i]))
            {
                AssetDatabase.AddObjectToAsset(_nodeList[i], assetsPath);
                assets.NodesList.Add(_nodeList[i]);
            }
        }
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }