public override IShaderProperty Copy()
        {
            var copied = new ColorShaderProperty();

            copied.displayName = displayName;
            copied.value       = value;
            return(copied);
        }
        public override AbstractShaderProperty Copy()
        {
            var copied = new ColorShaderProperty();

            copied.displayName = displayName;
            copied.value       = value;
            copied.hidden      = hidden;
            copied.colorMode   = colorMode;
            return(copied);
        }
Пример #3
0
        internal static void AddMainColorMenuOptions(ContextualMenuPopulateEvent evt, ColorShaderProperty colorProp, GraphData graphData, Action inspectorUpdateAction)
        {
            if (!graphData.isSubGraph)
            {
                if (!colorProp.isMainColor)
                {
                    evt.menu.AppendAction(
                        "Set as Main Color",
                        e =>
                    {
                        ColorShaderProperty col = graphData.GetMainColor();
                        if (col != null)
                        {
                            if (EditorUtility.DisplayDialog("Change Main Color Action", $"Are you sure you want to change the Main Color from {col.displayName} to {colorProp.displayName}?", "Yes", "Cancel"))
                            {
                                graphData.owner.RegisterCompleteObjectUndo("Change Main Color");
                                col.isMainColor       = false;
                                colorProp.isMainColor = true;
                                inspectorUpdateAction();
                            }
                            return;
                        }

                        graphData.owner.RegisterCompleteObjectUndo("Set Main Color");
                        colorProp.isMainColor = true;
                        inspectorUpdateAction();
                    });
                }
                else
                {
                    evt.menu.AppendAction(
                        "Clear Main Color",
                        e =>
                    {
                        graphData.owner.RegisterCompleteObjectUndo("Clear Main Color");
                        colorProp.isMainColor = false;
                        inspectorUpdateAction();
                    });
                }
            }
        }
Пример #4
0
        public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode)
        {
            if (!generationMode.IsPreview())
            {
                return;
            }

            var matOwner = owner as AbstractMaterialNode;

            if (matOwner == null)
            {
                throw new Exception(string.Format("Slot {0} either has no owner, or the owner is not a {1}", this, typeof(AbstractMaterialNode)));
            }

            var property = new ColorShaderProperty()
            {
                overrideReferenceName = matOwner.GetVariableNameForSlot(id),
                generatePropertyBlock = false,
                value = value
            };

            properties.AddShaderProperty(property);
        }