The Access Code says:
Picking wild berries and mushrooms
Customary picking of wild fungi and berries for your own consumption is not affected by the legislation. Care for the environment by following any agreed guidance on this activity. However, being on or crossing land or water for the purpose of taking away, for commercial purposes or for profit, anything in or on the land or water is excluded from access rights.
The Scottish Wild Mushroom Code provides further information on how to collect wild fungi responsibly.
Note, to clarify the information above, in accordance with the Land Reform (Scotland) Act 2003 (section 9), taking away mushrooms for commercial purposes or for profit requires the permission of the land owner/manager.