Tuesday, November 29, 2022
HomeGame DevelopmentYou're explicitly specifying `undefined` kind to cc property "gameManager" of cc class...

You’re explicitly specifying `undefined` kind to cc property “gameManager” of cc class “Lighty” – Cocos Creator


Whats up, after I set the property kind “GameManager” in my class “Lighty.ts” I obtained this error.
GameManager.ts imports the “Lighty” class too. It’s probablity why I obtained this error however I can’t perceive learn how to repair this.

cr.mjs:15 Discovered doable round reference in “http://localhost:7456/scripting/x/chunks/ce/cec23828dad35c5a650627fa53378b8a58384e48.js”, occurred when use “GameManager” imported from “./GameManager” Error
at Object.execute (Lighty.ts:24:21)
at doExec (system.js:482:32)
at postOrderExec (system.js:472:23)
at system.js:461:30
at Array.forEach ()
at postOrderExec (system.js:459:12)
at system.js:461:30
at Array.forEach ()
at postOrderExec (system.js:459:12)
at system.js:406:14
report @ cr.mjs:15
debug.ts:80 You’re explicitly specifying undefined kind to cc property “gameManager” of cc class “Lighty”.
Is that this meant? If not, this will point out a round reference.
For instance:

// foo.ts
import { _decorator } from ‘cc’;
import { Bar } from ‘./bar’; // On condition that ‘./bar’ additionally reference ‘foo.ts’.
// When importing ‘./bar’, execution of ‘./bar’ is held on to attend execution of ‘foo.ts’,
// the Bar imported right here is undefined till ‘./bar’ end its execution.
// It results in that
@_decorator.ccclass // ↓
export class Foo { // ↓
@_decorator.kind(Bar) // → is equal to @_decorator.kind(undefined)
public bar: Bar; // To eradicate this error, both:
// – Refactor your module construction(really helpful), or
// – specify the kind as cc class title: @_decorator.kind('Bar'/* or any title you specified for Bar */)
}

Right here is the property in my “Lighty” class

    //#area SerializeFields
    @property({ kind: GameManager })
    public gameManager: GameManager = null;

And in my GameManager class

    @property(Lighty)
    public lighty: Lighty | null;

Thanks.


You’re getting this error due to the round dependency downside. Your script “Lighty.ts” relies on “GameManager.ts” and “GameManager.ts” relies on “Lighty.ts”.

To repair this preserve your gameManager serialized in your “Lighty.ts” script and drag the GameManager node within the Inspector panel

In Lighty.ts

    @property(GameManager)
    gameManager: GameManager = null;

And in you “GameManager.ts” script use discover(“Lighty”) to go looking the Lighty node and getComponent(Lighty) to get the Lighty part. Learn extra about accessing nodes and parts.

In GameManager.ts

    lighty: Lighty = null;

    onLoad() {
        let lightyNode = discover("Lighty");
        if(lightyNode){
            this.lighty = lightyNode.getComponent(Lighty);
        }

    }

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments