There's a problem with the property in the inspector!

hi im korean developer!

To me, single-tone component A and
There is a generic component B that uses an instance of A.

Attach A and B components to different game objects.
If you try to put B in A’s Property,

The inspector is null and not working properly.

What should I do?

example)

import B from '...';
class A extends cc.Component{
    private static instance : A = null;
    public static get Instance() : A {
        return this.instance;
    }
    @property(B)
    public b : B = null;
    
    public helloWorld() {
        console.log("Hello World");
    }
}



import A from '...';
class B extends cc.Component {
    onLoad() {
        A.Instance.helloWorld();
    }
}

image

Please try the newly released 2.4.1

If you’re using a custom class that isn’t a component as your property, you need to tell Cocos Creator how to serialize it. You should use @ccclass('MyClassName') to define the serialized name for the class.

Also, yeah there’s issue with cyclic imports which is probably what you’re referring to here. A imports B and B imports A, and that doesn’t work so well in Cocos Creator. @slackmoehrle Is this issue fixed in 2.4.1?

Yes, it seems to be fixed in 2.4.1. Just tried it. It was quite a pain honestly to import inline as a workaround. (using import inside the code and not at the top)

1 Like

Thanks! im solved this problem!

Hi !
I am having this exact same problem but I’am in version 2.4.2 and using Typescript, is there any workaround?

Example code:

@ccclass
@menu("Dialog/DialogController")
export default class DialogController extends cc.Component{

@property(DialogUIController)
public dialogUI: DialogUIController = null;

and in the other:

@ccclass
    @menu("Dialog/DialogUIController")
    export default class DialogUIController extends cc.Component {
    @property(DialogController)
    public controller: DialogController = null;

Thanks

I think you need to add the class name after @ccclass
so like

@ccclass("DialogController)