My unity editor version is : 2018.4.1f1 Personal
I have a editor script :
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
[CustomEditor(typeof(ConversationTrigger))]
public class ConversationTriggerEditor : Editor
{
private ConversationTrigger _conversationTrigger;
[SerializeField] private ReorderableList conversationsList;
private SerializedProperty _conversations;
private int _currentlySelectedConversationIndex = -1;
private int newSize = 0;
private Vector2 scrollPos;
private readonly Dictionary<string, ReorderableList> _dialoguesListDict = new Dictionary<string, ReorderableList>();
private readonly Dictionary<string, ReorderableList> _sentencesListDict = new Dictionary<string, ReorderableList>();
private void OnEnable()
{
_conversationTrigger = (ConversationTrigger)target;
The variable _conversationTrigger is null and also target is “null”
They are both null when running the game but then when the game is continue the game is working fine without any problems. And both are not null again.
The exception message in the editor is :
InvalidCastException: Specified cast is not valid. On line 25.
Line 25 is :
_conversationTrigger = (ConversationTrigger)target;
When using a break point on the target I see :
cloneDestroyedMessage : “Instantiate failed because the clone was destroyed during creation. This can happen if DestroyImmediate is called in MonoBehaviour.Awake.” And objectisNullMessage : “The Object you want to instantiate is null.”
I’m not using any DestroyImmediate at any place in my project.
And :
UnityEngine.MissingReferenceException: The variable m_Targets of ConversationTriggerEditor doesn’t exist anymore. You probably need to reassign the m_Targets variable of the ‘ConversationTriggerEditor’ script in the inspector.
I checked many times everything is assigned in the editor.
The fact is that after few seconds they are not null and everything in the game is working fine.