Not what is the exception but why I'm getting it ?
MissingReferenceException: The object of type 'PlayConversations' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.
This is a screenshot before running the game. The script PlayConversations is only attached to the object Conversation Trigger :
After running the game at the point in the game it's trying to use the PlayConversations script I'm getting the exception. And I looked many times I can't find any object destroyed or that PlayConversations is not attached or destroyed or missing.
This is a screenshot after the game is running it's creating a Clone of the Player and I can still see the PlayConversations script :
This is the script :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayConversations : MonoBehaviour
{
private static ConversationTrigger conversationTrigger;
private static PlayConversations instance;
private void Awake()
{
conversationTrigger = GetComponent<ConversationTrigger>();
instance = this;
}
public static void AddConversationToPlay(int index)
{
ConversationTrigger.conversationsToPlay.Add(index);
}
public static void PlayMultipleConversations()
{
instance.StartCoroutine(conversationTrigger.PlayConversations());
}
public static void PlaySingleConversation(int ConversationIndex)
{
instance.StartCoroutine(conversationTrigger.PlayConversation(ConversationIndex));
}
}
The exception happens on the line :
instance.StartCoroutine(conversationTrigger.PlayConversation(ConversationIndex));
It seems like instance is null.