Custom Asset Support in Cocos Creator (3.8.x)

In Cocos Creator, there are built-in asset types like:

  • cc.JsonAsset
  • cc.SpriteFrame
  • cc.Prefab

These allow us to import files (JSON, images, prefabs, etc.) and assign them to @property fields in Components.


My Goal

I want to create my own custom asset type.

Example:

  • Create a custom file: .pts or .test
  • Store my own data
  • Drag this file into the Inspector
  • Use it like a normal asset in @property

What I Tried

Custom Asset Class

import { Asset, _decorator } from 'cc';

const { ccclass } = _decorator;

@ccclass("PleaseWork")
export class PleaseWork extends Asset {}

Editor Extension

  • Created extension
  • Used <ui-drag-item> and <ui-asset>
  • Edited .meta importer
  • Followed official docs

But it still doesn’t work.


Current Problem

Cocos Creator does not recognize .pts files as valid assets:

  • Cannot assign in Inspector
  • Not converted to custom Asset
  • Not importable

Question

How do I make Cocos Creator:

  • Recognize custom file types
  • Import them as Assets
  • Bind them to custom classes

Like JsonAsset or Prefab?

Please help. Thank you!

  • Followed official docs
    But it still doesn’t work.

I tried following the documentation and indeed, at least on Windows, it seems that some detail is missing for the extension to work properly.
Since your class extends Asset, you can use @property({ type: Asset }) newDataFile: PleaseWork; and drag and drop will work, however without restricting the asset type to the desired file type.