Пример #1
0
        internal static void AddMainTextureMenuOptions(ContextualMenuPopulateEvent evt, Texture2DShaderProperty texProp, GraphData graphData, Action inspectorUpdateAction)
        {
            if (!graphData.isSubGraph)
            {
                if (!texProp.isMainTexture)
                {
                    evt.menu.AppendAction(
                        "Set as Main Texture",
                        e =>
                    {
                        Texture2DShaderProperty tex = graphData.GetMainTexture();
                        // There's already a main texture, ask the user if they want to change and toggle the old one to not be main
                        if (tex != null)
                        {
                            if (EditorUtility.DisplayDialog("Change Main Texture Action", $"Are you sure you want to change the Main Texture from {tex.displayName} to {texProp.displayName}?", "Yes", "Cancel"))
                            {
                                graphData.owner.RegisterCompleteObjectUndo("Change Main Texture");
                                tex.isMainTexture     = false;
                                texProp.isMainTexture = true;
                                inspectorUpdateAction();
                            }
                            return;
                        }

                        graphData.owner.RegisterCompleteObjectUndo("Set Main Texture");
                        texProp.isMainTexture = true;
                        inspectorUpdateAction();
                    });
                }
                else
                {
                    evt.menu.AppendAction(
                        "Clear Main Texture",
                        e =>
                    {
                        graphData.owner.RegisterCompleteObjectUndo("Clear Main Texture");
                        texProp.isMainTexture = false;
                        inspectorUpdateAction();
                    });
                }
            }
        }