The Don't Repeat Yourself (DRY) acronym is the software developer's conscience: it tells you when you're in danger of making a bad or questionable decision, and gives you a feeling of satisfaction after a job well done.
In practice, repeated code is part of programming life. Trying to avoid it by constantly thinking ahead will put up so many roadblocks in your project that it won't seem worth it to continue. A more efficient—and sane—approach to dealing with repeating code is to quickly identify it when and where it occurs and then look for the best way to remove it. This task is called refactoring, and our GameBehavior class could use a little of its magic right now.
Time for action – creating a restart method
To refactor the existing level restart code, you'll need to update GameBehavior as follows:
publicclassGameBehavior:MonoBehaviour
{
// ... No changes needed ....