Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Component Retrieval Issue in Build (getComponent returns null) #17898

Open
tafedorov78 opened this issue Nov 20, 2024 · 6 comments
Open
Labels
Bug Needs Triage Needs to be assigned by the team

Comments

@tafedorov78
Copy link

Cocos Creator version

3.8.3

System information

chrome, macos, windows

Issue description

I’m experiencing an issue with a custom component attached to a node. When accessing the component locally using the getComponent method, it returns the expected component. However, when accessing the component remotely in a build from remote host, it returns null.
in the attached project - look at PrizeController --> const switcher2 = node.getComponent('NodeSwitchComponent');

Relevant error log output

null

Steps to reproduce

  1. Attach a custom component to a node.
  2. Access the component locally using getComponent - the component is retrieved correctly.
  3. Access the component remotely (remote host!!!) in a build - getComponent returns null.

Minimal reproduction project

test.zip

@tafedorov78 tafedorov78 added Bug Needs Triage Needs to be assigned by the team labels Nov 20, 2024
@longchuan
Copy link
Contributor

image
look at this

@longchuan
Copy link
Contributor

image
Thanks for I got a gift program😂

@tafedorov78
Copy link
Author

I don't think you got it. I mentioned it should be run it remotely, not on your local machine that the point.

@tafedorov78
Copy link
Author

I found one thing - if I set a target in tsconfig = es6 it does not work!

@longchuan
Copy link
Contributor

I don't think you got it. I mentioned it should be run it remotely, not on your local machine that the point.

A slowly network: http://119.3.232.55/web-mobile/index.html
image

@longchuan
Copy link
Contributor

The root path of import is the dir of script file.So,you should add "../" to return parent dir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Needs to be assigned by the team
Projects
None yet
Development

No branches or pull requests

2 participants