Beispiel #1
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();
                    });
                }
            }
        }