示例#1
0
        public Texture2dDisplayNode(Texture2D texture, Rect rect)
        {
            var labelSize   = style.fontSize * 4 + 4;
            var size        = new Vector2(rect.width, rect.height + labelSize);
            var textureSize = new Vector2(rect.width, rect.height);

            SetSize(new Vector2(132, rect.height + 78 + style.marginTop));
            m_Rect          = rect;
            m_Texture       = texture;
            m_RenderTexture = new RenderTexture(m_Texture.width, m_Texture.height, 1, RenderTextureFormat.ARGBFloat);
            m_RenderTexture.enableRandomWrite = true;

            m_DisplayConversionCompute = CommonResources.RFloatToRGBAFloatCompute;

            m_ImGui = new IMGUIContainer(OnGUI);

            m_ImGui.SetSize(textureSize);
            m_ImGui.style.positionType = new StyleValue <PositionType>(PositionType.Relative);

            title           = "Image Preview";
            input           = VisionPort.Create <Edge, Image <T> >(Orientation.Horizontal, Direction.Input, Port.Capacity.Single);
            input.onUpdate += OnInputUpdate;

            input.portName = string.Format("Image<{0}>", typeof(T).Name);
            inputContainer.Add(input);

            extensionContainer.SetSize(textureSize);
            extensionContainer.Add(m_ImGui);
            extensionContainer.style.positionType = PositionType.Relative;
            contentContainer.Add(extensionContainer);
            RefreshExpandedState();
        }