Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17076

CC 3.0 - Property Issue

$
0
0

Hello all,

I have a strange error when trying to do a thing like this:

@property({ type: Graphics })
public targeting: Graphics = new Graphics();
// OR
@property({ type: Node})
public targeting: Node= new Node();

After dragging a node or a node containing graphics component I am getting the following issue on runtime:

You are explicitly specifying `undefined` type to cc property "target" of cc class "cc.TargetOverrideInfo".
Is this intended? If not, this may indicate a circular reference.
For example:

 
// foo.ts
import { _decorator } from 'cc';
import { Bar } from './bar';  // Given that './bar' also reference 'foo.ts'.
                              // When importing './bar', execution of './bar' is hung on to wait execution of 'foo.ts',
                              // the `Bar` imported here is `undefined` until './bar' finish its execution.
                              // It leads to that
@_decorator.ccclass           //  ↓
export class Foo {            //  ↓
    @_decorator.type(Bar)     //  → is equivalent to `@_decorator.type(undefined)`
    public bar: Bar;          // To eliminate this error, either:
                              // - Refactor your module structure(recommended), or
                              // - specify the type as cc class name: `@_decorator.type('Bar'/* or any name you specified for `Bar` */)`
}

On Cocos Creator 2.X.X it worked just fine. What am I doing wrong here?

So I changed the code like this but no luck:

@property({ type: Graphics })
public targeting: Graphics;
// OR
@property({ type: Node})
public targeting: Node;
// Even tried this one:
@property
public targeting: Graphics;
// OR
@property
public targeting: Node;

Same error different place… Please help me here…

4 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 17076

Trending Articles