序列化显示问题

最近把做的一个小游戏迁移到了3.0,inspector面板上自定义属性的序列化显示出现了问题。
自定义一个item类
image

自定义数组
image

在inspector面板里显示是这样的
image

自定义属性里的内容完全没显示上去,请问该怎么解决,还是我的写法有问题?

https://docs.cocos.com/creator/3.0/manual/zh/scripting/ccclass.html item只是保存数据就没必要继承component了吧

然后就变成了这样
image

import { _decorator, CCInteger, SpriteFrame } from "cc";

const { ccclass, property } = _decorator;

@ccclass("Item")

export class Item {

  @property({

    displayName: "ID",

    type: CCInteger,

    serializable: true,

  } as any)

  public id: number = 0;

  @property({

    displayName: "Image",

    type: SpriteFrame,

    serializable: true,

  } as any)

  public img: SpriteFrame | null = null;

}
import { _decorator, Component, Node } from "cc";

import { Item } from "./Item";

const { ccclass, property } = _decorator;

@ccclass("ItemManager")

export class ItemManager extends Component {

  @property([Item])

  public items: Item[] = [];

}

4赞

非常感谢!

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。