Reusability of code

I have created One Button called Pause on my level one screen
it includes many operations like----
1)Restart
2)SoundOn/Off
3)Help
4)Resume

so i want this same menu in all the levels but i dont want to write code every time in every script for level2,level3 and on…

all this operations are under OnGUI function so how i resure this code for every level

please help me with C# code

thanks in advance

I have a main menu object with my menu code on it and a DontDestroyOnLoad script attached.

Place this code in its own script, then add this script to some object in each level. The player may be a good choice in single player games, since it’s present in every level. An alternative is to create an empty object (“GameControl”, or other meaningful name) and add this script to it - as well as any other game control script. Make this object a prefab, thus you can easily place a GameControl object in every level.

Another alternative is to create this object only in the first level and call DontDestroyOnLoad() at Start or Awake - but this approach creates problems when you try to test a level without executing the first one.