Beispiel #1
0
        private void ColorGUI()
        {
            // color type selection
            colorNode.type = (ColorNode.COLORTYPE)EditorGUILayout.EnumPopup(colorNode.type);
            if (colorNode.type != colorNode.lastType)
            {
                colorNode.SetInputs();
                UpdatePreview();
                colorNode.lastType = colorNode.type;
                node.title         = colorNode.type.ToString();
            }
            node.rect.height += controlHeight * 1.5f;

            switch (colorNode.type)
            {
            case ColorNode.COLORTYPE.GRADIENT:
                gradient = GUIGradientField.GradientField(gradient);

                //colorNode.gradient = (Gradient)gradient.GradientData;
                colorNode.gradientColorKeys = SerializableGradientColorKey.FromGradientColorKeys(colorNode.gradient.colorKeys);
                colorNode.gradientAlphaKeys = SerializableGradientAlphaKey.FromGradientColorKeys(colorNode.gradient.alphaKeys);

                node.rect.height += controlHeight * 1.5f;
                break;

            case ColorNode.COLORTYPE.COLOR:
                colorNode.color.FromColor(EditorGUILayout.ColorField(colorNode.color.ToColor()));
                break;
            }
        }
Beispiel #2
0
        public static GradientWrapper GradientField(GradientWrapper gradient, params GUILayoutOption[] options)
        {
            if (gradient == null)
            gradient = new GradientWrapper();

            gradient.GradientData = s_miGradientField2.Invoke(null, new object[] { gradient.GradientData, options });

            return gradient;
        }
Beispiel #3
0
        public static GradientWrapper GradientField(GradientWrapper gradient, params GUILayoutOption[] options)
        {
            if (gradient == null)
            {
                gradient = new GradientWrapper();
            }

            gradient.GradientData = s_miGradientField2.Invoke(null, new object[] { gradient.GradientData, options });

            return(gradient);
        }
Beispiel #4
0
        public NodeWindow(Node node)
        {
            this.windowIndex = indexCount;
            indexCount++;

            // cast to specific type
            if(node is GeneratorNode) {
            generatorNode = (GeneratorNode)node;
            type = WINDOWTYPE.GENERATOR;
            node.title = generatorNode.type.ToString();
            }
            if(node is OperatorNode){
            operatorNode = (OperatorNode)node;
            type = WINDOWTYPE.OPERATOR;
            node.title = operatorNode.type.ToString();
            }
            if(node is OutputNode) {
            outputNode = (OutputNode)node;
            type = WINDOWTYPE.OUTPUT;
            previewSize = PreviewSize.x2;
            }
            if(node is MacroNode) {
            macroNode = (MacroNode)node;
            type = WINDOWTYPE.MACRO;
            }
            if(node is TextureNode) {
            textureNode = (TextureNode)node;
            type = WINDOWTYPE.TEXTURE;
            }
            if(node is ColorNode) {
            colorNode = (ColorNode)node;

            gradient = new GradientWrapper();
            gradient.GradientData = colorNode.gradient;

            type = WINDOWTYPE.COLOR;
            }

            // also save general reference
            this.node = node;

            // random connection color
            connectionColor = new Color(Random.Range(100, 200) / 255f, Random.Range(100, 200) / 255f, Random.Range(100, 200) / 255f);

            UpdatePreview();
            node.rect.height = controlHeight + (int)previewSize;
            node.rect.width = (int)previewSize + 20;
            if(node.rect.width < 200)
            node.rect.width = 200;

            if(showOutputOptions)
            showOutputOptions = false;
        }
Beispiel #5
0
        private void ColorGUI()
        {
            // color type selection
            colorNode.type = (ColorNode.COLORTYPE)EditorGUILayout.EnumPopup(colorNode.type);
            if(colorNode.type != colorNode.lastType) {
            colorNode.SetInputs();
            UpdatePreview();
            colorNode.lastType = colorNode.type;
            node.title = colorNode.type.ToString();
            }
            node.rect.height += controlHeight * 1.5f;

            switch(colorNode.type) {
            case ColorNode.COLORTYPE.GRADIENT:
            gradient = GUIGradientField.GradientField(gradient);

            //colorNode.gradient = (Gradient)gradient.GradientData;
            colorNode.gradientColorKeys = SerializableGradientColorKey.FromGradientColorKeys(colorNode.gradient.colorKeys);
            colorNode.gradientAlphaKeys = SerializableGradientAlphaKey.FromGradientColorKeys(colorNode.gradient.alphaKeys);

            node.rect.height += controlHeight * 1.5f;
            break;
            case ColorNode.COLORTYPE.COLOR:
            colorNode.color.FromColor(EditorGUILayout.ColorField(colorNode.color.ToColor()));
            break;
            }
        }
Beispiel #6
0
        public NodeWindow(Node node)
        {
            this.windowIndex = indexCount;
            indexCount++;

            // cast to specific type
            if (node is GeneratorNode)
            {
                generatorNode = (GeneratorNode)node;
                type          = WINDOWTYPE.GENERATOR;
                node.title    = generatorNode.type.ToString();
            }
            if (node is OperatorNode)
            {
                operatorNode = (OperatorNode)node;
                type         = WINDOWTYPE.OPERATOR;
                node.title   = operatorNode.type.ToString();
            }
            if (node is OutputNode)
            {
                outputNode  = (OutputNode)node;
                type        = WINDOWTYPE.OUTPUT;
                previewSize = PreviewSize.x2;
            }
            if (node is MacroNode)
            {
                macroNode = (MacroNode)node;
                type      = WINDOWTYPE.MACRO;
            }
            if (node is TextureNode)
            {
                textureNode = (TextureNode)node;
                type        = WINDOWTYPE.TEXTURE;
            }
            if (node is ColorNode)
            {
                colorNode = (ColorNode)node;

                if (colorNode.gradient == null)
                {
                    colorNode.gradient = new Gradient();
                    if (colorNode.gradientColorKeys != null)
                    {
                        colorNode.gradient.colorKeys = SerializableGradientColorKey.ToGradientColorKeys(colorNode.gradientColorKeys);
                        colorNode.gradient.alphaKeys = SerializableGradientAlphaKey.ToGradientColorKeys(colorNode.gradientAlphaKeys);
                    }
                    gradient = new GradientWrapper();
                    gradient.GradientData = colorNode.gradient;
                }

                type = WINDOWTYPE.COLOR;
            }

            // also save general reference
            this.node = node;

            // random connection color
            connectionColor = new Color(Random.Range(100, 200) / 255f, Random.Range(100, 200) / 255f, Random.Range(100, 200) / 255f);

            UpdatePreview();
            node.rect.height = controlHeight + (int)previewSize;
            node.rect.width  = (int)previewSize + 20;
            if (node.rect.width < 200)
            {
                node.rect.width = 200;
            }
        }