Ejemplo n.º 1
0
        public InspectorView()
        {
            style.backgroundColor = new StyleColor(new Color(0.22f, 0.22f, 0.22f, 1f));
            _head = new VisualElement();
            _head.style.flexDirection   = new StyleEnum <FlexDirection>(FlexDirection.Row);
            _head.style.backgroundColor = new StyleColor(new Color(0.12f, 0.12f, 0.12f, 1f));
            _head.style.height          = 22;
            _head.style.unityTextAlign  = new StyleEnum <TextAnchor>(TextAnchor.MiddleCenter);
            _head.style.paddingLeft     = 5;
            Add(_head);
            var label = new Label("Inspector");

            label.style.color = new StyleColor(new Color(0.75f, 0.75f, 0.75f, 1f));
            _head.Add(label);

            _inspector = new InspectorElement();
            Add(_inspector);
        }
Ejemplo n.º 2
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);
            }
        }