Esempio n. 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;
            }
        }
Esempio n. 2
0
        override public ModuleBase GetModule()
        {
            // check that has inputs
            if (type != COLORTYPE.COLOR)
            {
                for (int i = 0; i < inputs.Length; i++)
                {
                    if (inputs[i] == null)
                    {
                        return(null);
                    }
                }
            }

            // get module
            switch (type)
            {
            case COLORTYPE.GRADIENT:
                if (gradient == null)
                {
                    gradient = new Gradient();
                    if (gradientColorKeys != null)
                    {
                        gradient.colorKeys = SerializableGradientColorKey.ToGradientColorKeys(gradientColorKeys);
                    }
                    if (gradientAlphaKeys != null)
                    {
                        gradient.alphaKeys = SerializableGradientAlphaKey.ToGradientColorKeys(gradientAlphaKeys);
                    }
                }
                if (gradientColorKeys == null)
                {
                    gradientColorKeys = SerializableGradientColorKey.FromGradientColorKeys(gradient.colorKeys);
                }
                if (gradientAlphaKeys == null)
                {
                    gradientAlphaKeys = SerializableGradientAlphaKey.FromGradientColorKeys(gradient.alphaKeys);
                }

                module = new GradientModule(inputs[0].GetModule(), gradient);
                break;

            case COLORTYPE.ADD:
                module = new AddColorModule(inputs[0].GetModule(), inputs[1].GetModule());
                break;

            case COLORTYPE.MULTIPLY:
                module = new MultiplyColorModule(inputs[0].GetModule(), inputs[1].GetModule());
                break;

            case COLORTYPE.BLEND:
                module = new BlendColorModule(inputs[0].GetModule(), inputs[1].GetModule(), inputs[2].GetModule());
                break;

            case COLORTYPE.COLOR:
                module = new ColorSource(color.ToColor());
                break;

            case COLORTYPE.OVERLAY:
                module = new OverlayColorModule(inputs[0].GetModule(), inputs[1].GetModule());
                break;
            }

            SetOutputOptions();

            return(this.module);
        }