Reply To: Ch5, MessagingClientReceiver

Home Forums Books Mastering Unity 2D Game Development Ch5, MessagingClientReceiver Reply To: Ch5, MessagingClientReceiver


Right, sorry to hear you are having troubles, let’s see what we can do.

Now I note that the error is stating place in the Start method of the MessagingClientReceiver script, the only thing in the start method is the following:

So the only possible reason I can think this would cause an error was if the MessagingManager script you are using is not implementing the Singleton pattern.

You might want to check the beginning of the MessagingManager script and ensure it looks as follows:

public class MessagingManager : Singleton
protected MessagingManager() { }
// guarantee this will be always a singleton only – can’t use the constructor!

Note, the use of the Singleton as the base of the script which uses the generic singleton behaviour I describe in Chapter 5 with the ConversationManager.
You can also see this implemented in the downloadable code in chapter 6 (as the chapter suggests you implement the same behaviour for the messaging manager.

Alternatively, you can keep the MessagingManager as it is, but ensure that the STATIC property on the script it there called Instance, as shown below:

// Static singleton property
public static MessagingManager Instance { get; private set; }

But I’d recommend the first approach.

Hope this helps.

Simon (Darkside) Jackson