I'm making a Unity game, and I want to use the Unity Distribution Portal.

My problem is that you have to make a script named GameManager for this, but I already have another script called GameManager, so every time I try to rename the first GameManager script, the game stops working.

I don't want to rewrite every script I've used GameManager variables in. So the way I've been trying to rename this is by right-clicking on the GameManager.cs file in the Unity project window and renaming it there, then typing a 2 in the name inside Visual Studio.

If I call the script for UDP for example something like GameManager2, UDP doesn't seem to understand that this is the script it needs for Sandbox Testing.

Can anyone help me with this?

Here is the UDP script I want to add (which is currently called GameManager2, but needs to be called GameManager):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UDP;

public class InitListener : MonoBehaviour, IInitListener
    public IInitListener listener;
    public void Start()

    public void OnInitialized(UserInfo userInfo)
        Debug.Log("Initialization succeeded");    

    public void OnInitializeFailed(string message)
        Debug.Log("Initialization failed: " + message);
  • \$\begingroup\$ The script code you've included in the question has no reference to a GameManager at all. Are you sure that's the code that's giving you trouble? \$\endgroup\$
    – DMGregory
    Dec 13, 2020 at 19:11
  • \$\begingroup\$ I think so... Or do you need a different code for doing Sandbox Testing... then please tell me! \$\endgroup\$ Dec 13, 2020 at 19:38
  • 1
    \$\begingroup\$ What a timely question, so thank for telling me something I needed to know. I was considering using UDP with my next project, and I have a class with the almost conflicting name GameController, so I should be careful! although I use namespaces so maybe I would've been fine anyway... \$\endgroup\$
    – jhocking
    Dec 13, 2020 at 20:29

1 Answer 1


When you just type a new name in a class, that doesn't change all the other code files that are trying to refer to that class's name. So you'll get all kinds of compiler errors because they're now referring to a name that doesn't exist.

Instead, you should right-click on the identifier you want to change, and select Rename (or press F2 as a shortcut)

Rename option

Instances of that name will be highlighted in green, and will all be updated in-sync as you modify the name. A box in the corner will tell you how many references in how many files are going to be changed (and warn you of any conflicts).

Renaming in progress

When you're happy with the new name, click Apply or press Enter to accept the change and save all the files modified in the process.

Do this before adding the Unity Distribution Portal content to your project, to be sure you don't accidentally mess up any of its references to its own Game Manager script.

I'd also recommend choosing a more informative name than GameManager2 - maybe LocalGameManager or PongGameManager (if you're making a "Pong" game), etc. Something that will remind you in 6 months which file is "your" version of the game manager and which one you got from the distribution portal guide.

  • \$\begingroup\$ Thank you... but now it shows me multiple (20) "The type or namespace name '...' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)" and "The type or namespace name '...' could not be found (are you missing a using directive or an assembly reference?)" messages \$\endgroup\$ Dec 13, 2020 at 19:35
  • \$\begingroup\$ It sounds like you accidentally renamed something "...", which is not a valid identifier. \$\endgroup\$
    – DMGregory
    Dec 13, 2020 at 20:21
  • \$\begingroup\$ Things that are between the "..." are: UDP, IInitListener, UserInfo, ILicencingListener, LicensingCode, LicensingErrorCode, IPurchaseListener, PurchaseInfo & Inventory... How can you make the errors disapear by using those? I´ve definitely not renamed them! \$\endgroup\$ Dec 14, 2020 at 13:30
  • \$\begingroup\$ Sounds like an unrelated problem. Your code might be missing a using statement to tell the compiler where to find those items, or you might not have correctly imported the UDP scripts into your project. \$\endgroup\$
    – DMGregory
    Dec 14, 2020 at 13:32
  • \$\begingroup\$ I´ve used the using, so I´m going delete (or downdate) all files i´ve done something during the UDP progress, reimport UDP through the Assets store and then i´ll question again, what to do next. \$\endgroup\$ Dec 14, 2020 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .