[SerializeReference]Error:FindScriptClass - Invalid serialize reference type dependency

I’m going to build nodegraph with editor extensions,and I need to store nodegraph resource assets,which contains a [SerializeReference] List<BaseNode>.BaseNode is a custom class that stores datas and dosen’t inherit from any classes.
Now I want to store it’s subclass,but whenerver Unity recompiles scripts it keeps warning if any nodegraphs contain respective node types.Note that it doesn’t cause any problem seemingly.

FindScriptClass - Invalid serialize reference type dependency name: ‘MikanLab.Item, MikanLab.Better Inspector.Runtime’’

Assembly name and class name is correct, and related scripts don’t change.

MikanLab.Item is one of BaseNode’s subclasses,it just declares two extra int fields.

Below are some of my scripts.I would appreciate if you can solve my problem:

[Serializable]
public class NodeGraph : ScriptableObject
{
    [SerializeReference] public List<BaseNode> NodeList = new();
}
[Serializable]
public abstract class BaseNode
{

    [Serializable]
    public class PortData
    {
        public string PortType;
        public bool AllowMultiple;
        public List<EdgeData> Edges = new();
    }

    [Serializable]
    public class EdgeData
    {
        public string TargetPortName;
        public int TargetIndex;
    }

    [NonSerialized] public NodeGraph Owner;

    [SerializeField] public PortDictionary InputPorts = new();
    [SerializeField] public PortDictionary OutputPorts = new();
    [SerializeField] public string NodeName = "";
    [SerializeField] public Vector2 Position = new(0, 0);
    [SerializeField] public bool Deleteable = true;
}
[UsedFor(typeof(RandomPool))]
class Item : InOutNode
{
    public int item;
    public int count;

    public Item()
    {
        NodeName = "Choice";
    }
}

I don’t think this is it, but have you tried adding [Serializable] to your item class?

Yes,all of basenode‘s subclasses define [Serializeable] but result doesn’t change.

Is this how the serialized data in the scene/scriptable object yaml actually looks? If so that would be weird and wrong.

The actual serialized data for a [SerializeReference] managed reference should look like this:

type: {class: MyClassName, ns: MyGame.MyNamespace, asm: MyAssembly}

Perhaps open your scene or asset in a text editor and double check this.

As to how the data got written wrong, sounds like an engine bug?

Well,this is the asset file:

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 0}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 00107e7425928f1408e71db6f2401aa0, type: 3}
  m_Name: RandomPool
  m_EditorClassIdentifier: 
  NodeList:
  - rid: 6424106806176120832
  - rid: 6424106806176120833
  ParametersList: []
  CountMode: 0
  references:
    version: 2
    RefIds:
    - rid: 6424106806176120832
      type: {class: Input, ns: MikanLab, asm: MikanLab.Better Inspector.Runtime}
      data:
        InputPorts:
          keys: []
          values: []
        OutputPorts:
          keys:
          - Link
          values:
          - PortType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
            AllowMultiple: 1
            Edges: []
        NodeName: "\u8F93\u5165"
        Position: {x: 100, y: 0}
        Deleteable: 1
    - rid: 6424106806176120833
      type: {class: Output, ns: MikanLab, asm: MikanLab.Better Inspector.Runtime}
      data:
        InputPorts:
          keys:
          - Result
          values:
          - PortType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
            AllowMultiple: 1
            Edges: []
        OutputPorts:
          keys: []
          values: []
        NodeName: "\u8F93\u51FA"
        Position: {x: 97.71429, y: 106.85715}
        Deleteable: 1

Sounds like the type is all right.

There seems to be a space between Better and Inspector in the asm name. Maybe that’s it?

2 Likes

Wow,that’s the case.It turned out to be right to delete the space.
Thanks for answering :slightly_smiling_face:

1 Like