示例#1
0
        public void Load(JSON js, string filePath)
        {
            ClearAll();

            SetFilePath(filePath);
            _name = js.ToString("name");

            JSON[] nodeListJS = js.ToArray <JSON>("bTree");
            for (int i = 0; i < nodeListJS.Length; ++i)
            {
                float           posX     = nodeListJS[i].ToFloat("posX");
                float           posY     = nodeListJS[i].ToFloat("posY");
                ZNode.BASE_TYPE baseType = ZEditorUtils.ParseEnum <ZNode.BASE_TYPE>(nodeListJS[i].ToString("baseType"));
                ZNode           newNode  = null;
                if (baseType == ZNode.BASE_TYPE.ROOT)
                {
                    newNode = CreateRoot(posX, posY);
                }
                else if (baseType == ZNode.BASE_TYPE.SUBTREE)
                {
                    newNode = CreateBaseNode(baseType, posX, posY, nodeListJS[i]);
                }
                else if (baseType == ZNode.BASE_TYPE.COMPOSITE)
                {
                    ZNodeComposite.NODE_TYPE nodeType = ZEditorUtils.ParseEnum <ZNodeComposite.NODE_TYPE>(nodeListJS[i].ToString("nodeType"));
                    newNode = CreateCompositeNode(nodeType, posX, posY, nodeListJS[i]);
                }
                else if (baseType == ZNode.BASE_TYPE.DECORATOR)
                {
                    ZNodeDecorator.NODE_TYPE nodeType = ZEditorUtils.ParseEnum <ZNodeDecorator.NODE_TYPE>(nodeListJS[i].ToString("nodeType"));
                    newNode = CreateDecoratorNode(nodeType, posX, posY, nodeListJS[i]);
                }
                else if (baseType == ZNode.BASE_TYPE.ACTION)
                {
                    ZBTActionManager.NODE_TYPE nodeType = ZEditorUtils.ParseEnum <ZBTActionManager.NODE_TYPE>(nodeListJS[i].ToString("nodeType"));
                    newNode = CreateActionNode(nodeType, posX, posY, nodeListJS[i]);
                }
                newNode.Name = nodeListJS[i].ToString("id");
            }

            JSON[] connectionListJS = js.ToArray <JSON>("connections");
            for (int i = 0; i < connectionListJS.Length; ++i)
            {
                int            inId         = connectionListJS[i].ToInt("inNodeId");
                int            outId        = connectionListJS[i].ToInt("outNodeId");
                ZNodeConnector inConnector  = GetNode(inId).OutConnector;
                ZNodeConnector outConnector = GetNode(outId).InConnector;
                if (inConnector != null && outConnector != null)
                {
                    CreateConnection(inConnector, outConnector);
                }
                else
                {
                    Debug.Log("Unable to find in or out connector for node: " + inId.ToString() + " " + outId.ToString());
                }
            }
        }
示例#2
0
        public void SetupSkinParams()
        {
            _rect = new Rect(0, 0, _parentNode.NodeEditor.SkinItem.inConnectorSize, _parentNode.NodeEditor.SkinItem.inConnectorSize);
            Texture buttonStyleType         = _parentNode.NodeEditor.SkinItem.defaultInConnector;
            Texture selectedButtonStyleType = _parentNode.NodeEditor.SkinItem.selectedInConnector;
            Texture filledStyleType         = _parentNode.NodeEditor.SkinItem.filledInConnector;

            if (_type == TYPE.OUT)
            {
                buttonStyleType         = _parentNode.NodeEditor.SkinItem.defaultOutConnector;
                selectedButtonStyleType = _parentNode.NodeEditor.SkinItem.selectedOutConnector;
                filledStyleType         = _parentNode.NodeEditor.SkinItem.filledOutConnector;
                _rect = new Rect(0, 0, _parentNode.NodeEditor.SkinItem.outConnectorSize, _parentNode.NodeEditor.SkinItem.outConnectorSize);
            }

            _defaultStyle  = ZEditorUtils.CreateGUIStyle(buttonStyleType);
            _selectedStyle = ZEditorUtils.CreateGUIStyle(selectedButtonStyleType);
            _filledStyle   = ZEditorUtils.CreateGUIStyle(filledStyleType);
        }
示例#3
0
        public ZNodeCreator(ZNodeEditor editor)
        {
            _editor = editor;

            _editor.OnNodeSelected += OnNodeSelected;

            _titleStyle           = new GUIStyle("WhiteLabel");
            _titleStyle.alignment = TextAnchor.MiddleCenter;
            _titleStyle.fontStyle = FontStyle.Bold;

            _textStyle           = new GUIStyle("WhiteLabel");
            _textStyle.alignment = TextAnchor.MiddleLeft;
            _textStyle.fontStyle = FontStyle.Normal;

            _searchStyle  = ZEditorUtils.CreateGUIStyle(_editor.SkinItem.searchIcon);
            _searchString = "";

            _compositeNodeList = (ZNodeComposite.NODE_TYPE[])System.Enum.GetValues(typeof(ZNodeComposite.NODE_TYPE));
            _decoratorNodeList = (ZNodeDecorator.NODE_TYPE[])System.Enum.GetValues(typeof(ZNodeDecorator.NODE_TYPE));
            _actionNodeList    = (ZBTActionManager.NODE_TYPE[])System.Enum.GetValues(typeof(ZBTActionManager.NODE_TYPE));
        }
示例#4
0
        void SetupSkinParams()
        {
            _xStyle    = ZEditorUtils.CreateGUIStyle(_editorSkinItem.x);
            _plusStyle = ZEditorUtils.CreateGUIStyle(_editorSkinItem.plus);
            _leftArrowInactiveStyle  = ZEditorUtils.CreateGUIStyle(_editorSkinItem.leftArrowInactive);
            _leftArrowActiveStyle    = ZEditorUtils.CreateGUIStyle(_editorSkinItem.leftArrowActive);
            _rightArrowInactiveStyle = ZEditorUtils.CreateGUIStyle(_editorSkinItem.rightArrowInactive);
            _rightArrowActiveStyle   = ZEditorUtils.CreateGUIStyle(_editorSkinItem.rightArrowActive);
            _zoomInStyle             = ZEditorUtils.CreateGUIStyle(_editorSkinItem.zoomIn);
            _zoomOutStyle            = ZEditorUtils.CreateGUIStyle(_editorSkinItem.zoomOut);

            _minZoom     = _editorSkinItem.minZoom;
            _maxZoom     = _editorSkinItem.maxZoom;
            _currentZoom = _editorSkinItem.startZoom;

            if (_currentNodeTree != null)
            {
                _currentNodeTree.RefreshSkin();
                if (_editorSkinItem.autoLayoutAsDefault)
                {
                    _currentNodeTree.AutoLayout();
                }
            }
        }
示例#5
0
 static void CreateView()
 {
     ZEditorUtils.CreateScriptableObject <ZNodeEditorSkin>(EDITOR_SKIN_PATH);
 }