Ejemplo n.º 1
0
        public virtual void InputDraw(EditorActionNode node, ScriptableObject asset)
        {
            var nodeTypeInfo = NodeTypeInfo.GetNodeTypeInfo(asset.GetType());
            List <NodeTypeInfo.IOInfo> list = new List <NodeTypeInfo.IOInfo>();

            list.AddRange(nodeTypeInfo.Inputs);
            list.AddRange(nodeTypeInfo.BTInputs);

            foreach (var inputInfo in list)
            {
                if (inputInfo.Mode == NodeTypeInfo.IOMode.BTInput)
                {
                    Port.Capacity capacity = Port.Capacity.Single;
                    var           portIn   = node.InstantiatePort(Orientation.Vertical, Direction.Input, capacity, null);
                    portIn.portColor        = NodeTypeInfo.IOModeColor(inputInfo.Mode);
                    portIn.portName         = string.Empty;
                    portIn.source           = inputInfo;
                    portIn.style.paddingTop = 2;
                    node.titleContainer.Add(portIn);
                    node.titleContainer.style.justifyContent = Justify.FlexStart;
                    node.titleButtonContainer.style.display  = DisplayStyle.None;
                }
                else
                {
                    Port.Capacity capacity = Port.Capacity.Multi;
                    var           portIn   = node.InstantiatePort(Orientation.Horizontal, Direction.Input, capacity, null);
                    portIn.portColor = NodeTypeInfo.IOModeColor(inputInfo.Mode);
                    portIn.portName  = inputInfo.GetName();
                    portIn.source    = inputInfo;
                    node.inputContainer.Add(portIn);
                }
            }
        }
Ejemplo n.º 2
0
 public EditorNodeElement(INode so, EditorActionNode node)
 {
     _so       = so;
     _node     = node;
     _typeInfo = NodeTypeInfo.GetNodeTypeInfo(so.GetType());
     CreateFieldElement();
 }
Ejemplo n.º 3
0
 public EditorNodeElement(SerializedProperty so, EditorActionNode node)
 {
     _so       = so;
     _node     = node;
     _typeInfo = NodeTypeInfo.GetNodeTypeInfo(so.GetValueType());
     CreateFieldElement();
 }
Ejemplo n.º 4
0
        public virtual void OutputDraw(EditorActionNode node, INode asset)
        {
            var nodeTypeInfo = NodeTypeInfo.GetNodeTypeInfo(asset.GetType());

            for (int i = 0; i < nodeTypeInfo.Outputs.Count; i++)
            {
                var outputInfo = nodeTypeInfo.Outputs[i];

                Port.Capacity capacity = (outputInfo.Mode == NodeTypeInfo.IOMode.BTOutput) ? Port.Capacity.Single : Port.Capacity.Multi;
                var           port     = node.InstantiatePort(Orientation.Horizontal, Direction.Output, capacity, null);
                port.portName  = outputInfo.GetName();
                port.source    = outputInfo;
                port.portColor = NodeTypeInfo.IOModeColor(outputInfo.Mode);
                node.outputContainer.Add(port);
            }
        }
Ejemplo n.º 5
0
 public static NodeTypeInfo GetNodeTypeInfo(Type type)
 {
     //if(typeof(NodeAsset<>) != type.BaseType.GetGenericTypeDefinition())
     //{
     //    throw new Exception("type需要是NodeAsset<>的子类");
     //}
     if (_typeInfos == null)
     {
         _typeInfos = new Dictionary <Type, NodeTypeInfo>();
     }
     if (_typeInfos.TryGetValue(type, out var info))
     {
         return(info);
     }
     info = new NodeTypeInfo(type);
     _typeInfos.Add(type, info);
     return(info);
 }
Ejemplo n.º 6
0
        private void InputDraw(INode asset)
        {
            var nodeTypeInfo = NodeTypeInfo.GetNodeTypeInfo(asset.GetType());
            var list         = new List <NodeTypeInfo.IOInfo>();

            list.AddRange(nodeTypeInfo.Inputs);
            list.AddRange(nodeTypeInfo.BTInputs);

            foreach (var inputInfo in list)
            {
                var capacity = inputInfo.Mode == NodeTypeInfo.IOMode.BTInput? Port.Capacity.Single:Port.Capacity.Multi;
                var portIn   = InstantiatePort(Orientation.Horizontal, Direction.Input, capacity, null);
                portIn.portColor = NodeTypeInfo.IOModeColor(inputInfo.Mode);
                portIn.portName  = inputInfo.GetName();
                portIn.source    = inputInfo;
                inputContainer.Add(portIn);
            }
        }
Ejemplo n.º 7
0
        private VisualElement AddElement(int i)
        {
            var arrItem = new VisualElement();

            arrItem.AddToClassList("node-field");

            if (_fieldInfo.IOInfo != null)
            {
                var portIn = _node.InstantiatePort(Orientation.Horizontal, Direction.Input, Port.Capacity.Single, null);
                portIn.source    = Clone(_fieldInfo.IOInfo, i);
                portIn.portName  = _fieldInfo.Name;
                portIn.portColor = NodeTypeInfo.IOModeColor(NodeTypeInfo.IOMode.InputParm);
                portIn.AddToClassList("inputparm-field");
                arrItem.Add(portIn);
            }
            else
            {
                //var label = new Label(_fieldInfo.Name);
                //label.AddToClassList("node-field-label");
                //arrItem.Add(label);
            }

            //var arrayItem = _sp.GetArrayElementAtIndex(i);
            //var be = ElementGenerate.Generate(_elementType, _sp, arrayItem.propertyPath);// $"{_fieldInfo.Path}.Array.Data[{i}]");
            var be = ElementGenerate.Generate(_elementType, _sp);

            if (be != null)
            {
                arrItem.Add(be);
            }


            var port = _node.InstantiatePort(Orientation.Vertical, Direction.Output, Port.Capacity.Single, null);

            port.source    = Clone(_fieldInfo.BT_IOInfo, i);
            port.portColor = NodeTypeInfo.IOModeColor(_fieldInfo.BT_IOInfo.Mode);
            port.portName  = "";// item.IOInfo.Name;
            port.AddToClassList("outputparm-field");
            //_node.Add(port);
            arrItem.Add(port);
            return(arrItem);
        }
Ejemplo n.º 8
0
        private void OutputDraw(INode asset)
        {
            var nodeTypeInfo = NodeTypeInfo.GetNodeTypeInfo(asset.GetType());

            foreach (var outputInfo in nodeTypeInfo.Outputs)
            {
                var capacity = outputInfo.Mode == NodeTypeInfo.IOMode.BTOutput ? Port.Capacity.Single : Port.Capacity.Multi;
                var port     = InstantiatePort(Orientation.Horizontal, Direction.Output, capacity, null);
                port.portName  = outputInfo.GetName();
                port.source    = outputInfo;
                port.portColor = NodeTypeInfo.IOModeColor(outputInfo.Mode);
                outputContainer.Add(port);
            }

            if (nodeTypeInfo.BTOutput != null)
            {
                var count = Math.Min(nodeTypeInfo.BTOutput.MaxLink, 20);
                for (var i = 0; i < count; i++)
                {
                    var capacity = Port.Capacity.Single;
                    var port     = InstantiatePort(Orientation.Horizontal, Direction.Output, capacity, null);
                    if (count > 1)
                    {
                        port.AddToClassList("small-port");
                    }

                    port.portName = i.ToString();
                    var newIOInfo = nodeTypeInfo.BTOutput.IOInfo.Clone();
                    newIOInfo.ID  += i;
                    port.source    = newIOInfo;
                    port.portColor = NodeTypeInfo.IOModeColor(NodeTypeInfo.IOMode.BTOutput);

                    outputContainer.Add(port);
                }
            }
        }
Ejemplo n.º 9
0
        private void CreateFieldElement()
        {
            var element = new InspectorElement(_so);

            Add(element);
            return;

            var mSo        = _so;
            var fieldInfos = _typeInfo.FieldInfos;

            foreach (var item in fieldInfos)
            {
                var ve = new VisualElement();
                ve.AddToClassList("node-field");

                if (item.FieldType.IsArray && (item.MaxLink != -1)) //|| item.IOInfo != null
                {
//                    var arrayField = new NodeArrayField(mSO, item.Path, item, _node);
//                    ve.Add(arrayField);
                }
                else
                {
                    Port outPort = null;
                    if (item.IOInfo != null)
                    {
                        if (item.IOInfo.Mode == NodeTypeInfo.IOMode.InputParm)
                        {
                            var portIn = _node.InstantiatePort(Orientation.Horizontal, Direction.Input, Port.Capacity.Single, null);
                            portIn.source    = item.IOInfo;
                            portIn.portName  = item.IOInfo.Name;
                            portIn.portColor = NodeTypeInfo.IOModeColor(NodeTypeInfo.IOMode.InputParm);
                            portIn.AddToClassList("inputparm-field");
                            ve.Add(portIn);
                        }
                        else if (item.IOInfo.Mode == NodeTypeInfo.IOMode.OutputParm)
                        {
                            var port = _node.InstantiatePort(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi, null);
                            port.source    = item.IOInfo;
                            port.portName  = "";// item.IOInfo.Name;
                            port.portColor = NodeTypeInfo.IOModeColor(NodeTypeInfo.IOMode.OutputParm);
                            port.AddToClassList("outputparm-field");
                            outPort = port;
                        }
                    }
                    else if (item.BT_IOInfo != null)
                    {
                        var port = _node.InstantiatePort(Orientation.Horizontal, Direction.Output, Port.Capacity.Single, null);
                        port.source    = item.BT_IOInfo;
                        port.portName  = "";// item.IOInfo.Name;
                        port.portColor = NodeTypeInfo.IOModeColor(NodeTypeInfo.IOMode.BTOutput);
                        port.AddToClassList("outputparm-field");
                        outPort = port;
                    }

                    if (item.Name != string.Empty && (item.IOInfo == null || outPort != null))
                    {
                        //ve.Add(GetField(mSO, item.Path, item.Name)); TODO:Re
                    }
                    else
                    {
                        //ve.Add(GetField(mSO, item.Path)); TODO:Re
                    }

                    //AddField(ve, item.FieldType, mSO, item.Path);
                    if (outPort != null)
                    {
                        ve.Add(outPort);
                    }
                }

                Add(ve);
            }

            var outputParms = _typeInfo.OutputParm;

            foreach (var item in outputParms)
            {
                var ve = new VisualElement();
                ve.AddToClassList("node-field");
                ve.AddToClassList("outputparm-method");

                var port = _node.InstantiatePort(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi, null);
                port.source   = item;
                port.portName = item.Name;

                ve.Add(port);
                Add(ve);
            }

            if (_typeInfo.BTOutput != null)
            {
                var ve = new VisualElement();
                ve.AddToClassList("node-field");
                ve.AddToClassList("outputparm-method");

                var port = _node.InstantiatePort(Orientation.Vertical, Direction.Output, Port.Capacity.Single, null);
                port.portName  = string.Empty;
                port.source    = _typeInfo.BTOutput.IOInfo;
                port.portColor = NodeTypeInfo.IOModeColor(_typeInfo.BTOutput.IOInfo.Mode);

                ve.Add(port);
                var _content = new VisualElement();
                _content.AddToClassList("node-array-content");
                _content.Add(ve);
                Add(_content);
            }
        }