Пример #1
0
        static NodeEditorConfig GetDefaultConfig()
        {
            NodeEditorConfig config = new NodeEditorConfig();

            config.InputsOutputs = new NodeEditorConfig.InputsOutputsData()
            {
                Shape   = ShapeType.Round,
                Size    = 9,
                Edge    = 0.2f,
                Padding = 2
            };
            config.BackgroundColor = new Color(0.78431374f, 0.78431374f, 0.78431374f, 1f);
            config.NodeColor       = new Color(1f, 1f, 1f, 0.19607843f);

            config.Colors = new[]
            {
                new Color(1f, 1f, 1f, 1f),
                new Color(0.74509805f, 0f, 0.74509805f, 1f),
                new Color(0.81353325f, 0.9012218f, 0.9019608f, 1f),
                new Color(0.5697809f, 0.65573025f, 0.74509805f, 1f),
                new Color(0.52733564f, 0.91551334f, 0.9960785f, 0.50980395f),
                new Color(0.29411763f, 0.6401771f, 1f, 0.627451f),
                new Color(0.29411763f, 0.52220225f, 1f, 0.627451f),
                new Color(0.3333333f, 0.43732592f, 1f, 0.627451f),
                new Color(1f, 0.58495826f, 0f, 0.316f),
                new Color(0.94f, 0.64509803f, 0.64509803f, 1f),
                new Color(0.703f, 0.57654524f, 0.553964f, 1f),
                new Color(0.16470589f, 0.8980393f, 0.1137255f, 1f),
                new Color(0.16470589f, 0.8980393f, 0.1137255f, 1f),
                new Color(0.16470589f, 0.8980393f, 0.1137255f, 1f),
                new Color(1f, 1f, 1f, 1f),
                new Color(1f, 1f, 1f, 1f)
            };

            return(config);
        }
 void OnEnable()
 {
     _config = (NodeEditorConfig)target;
 }
Пример #3
0
        public static void Initialize()
        {
            if (BackgroundGrid != null && Background != null)
            {
                return;
            }

            const float bg    = 0.35f;
            const float lines = 0.3f;

            BackgroundGrid = GetGridTexture((int)CellSize, new Color(bg, bg, bg, 1f), new Color(lines, lines, lines, 1f));


            Background = new GUIStyle("flow background");

            Node       = new GUIStyle("flow node 0");//TE NodeBox
            NodeActive = new GUIStyle("flow node 0 on");

            DefaultValue = new GUIStyle("miniButton");


            Title                  = new GUIStyle("ShurikenLabel");
            Title.alignment        = TextAnchor.LowerCenter;
            Title.fontStyle        = FontStyle.Bold;
            Title.normal.textColor = Gray(1f, 1f);
            //Title.normal.background = GetRectTexture(Gray(0, 0.2f), Gray(0.0f, 0.4f));
            Title.border = new RectOffset(1, 1, 1, 1);

            NodeEditorConfig config = NodeEditorConfig.Instance;

            if (config == null)
            {
                config = GetDefaultConfig();
            }
            var ioConfig = config.InputsOutputs;

            if (config.InputsOutputs.Shape == ShapeType.Round)
            {
                GraphicPoint                         = new GUIStyle();
                GraphicPoint.margin                  = GraphicPoint.padding = new RectOffset();
                GraphicPoint.normal.background       = GetRoundTexture(Gray(0.8f, 0), Gray(0.8f, 1), ioConfig.Edge, ioConfig.Size);
                GraphicPoint.border                  = new RectOffset();
                GraphicPointActive                   = new GUIStyle(GraphicPoint);
                GraphicPointActive.normal.background = GetRoundTexture(Gray(1, 0), Gray(1, 1), ioConfig.Edge, ioConfig.Size);
            }
            else
            {
                GraphicPoint = new GUIStyle("box");//flow overlay box, HelpBox
                GraphicPoint.normal.background       = GetRectTexture(Gray(0.8f, 1f), Gray(0.4f, 1f));
                GraphicPoint.border                  = new RectOffset(1, 1, 1, 1);
                GraphicPointActive                   = new GUIStyle(GraphicPoint);
                GraphicPointActive.normal.background = GetRectTexture(Gray(1, 1f), Gray(0.6f, 1f));
            }
            float halfSize = ioConfig.Size * 0.5f;

            InputShift      = new Vector2(-ioConfig.Size - ioConfig.Padding, CellSize * 0.5f - halfSize);
            OutputShift     = new Vector2(ioConfig.Padding, -halfSize);
            InputLinkShift  = -halfSize - ioConfig.Padding;
            OutputLinkShift = halfSize + ioConfig.Padding;
            IOSize          = ioConfig.Size;

            TypeColors      = config.Colors;
            BackgroundColor = config.BackgroundColor;
            NodeColor       = config.NodeColor;


            BigMessageLabel           = new GUIStyle("HeaderLabel");
            BigMessageLabel.fontSize  = 32;
            BigMessageLabel.alignment = TextAnchor.MiddleCenter;


            ExternalIndicator = new GUIStyle();
            ExternalIndicator.imagePosition = ImagePosition.ImageOnly;
            ExternalIndicator.alignment     = TextAnchor.UpperRight;
            ExternalIndicator.padding       = new RectOffset(3, 3, 3, 3);
            ExternalIndicatorImage          = GetRoundTexture(Gray(1, 0), Gray(1, 1), 0.6f, 8);
            ExternalIndicatorImageShadow    = GetRoundTexture(Gray(1, 0), Gray(1, 1), 0.2f, 8);
        }