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

Object.new() ignores scene settings if script has a class_name #42640

Closed
selamba opened this issue Oct 8, 2020 · 1 comment
Closed

Object.new() ignores scene settings if script has a class_name #42640

selamba opened this issue Oct 8, 2020 · 1 comment
Labels

Comments

@selamba
Copy link

selamba commented Oct 8, 2020

Godot version:
3.2.3.stable.official

OS/device including version:
Pop_os 20.04

Issue description:
First of all, I honestly don't know wether this should be a bug report or a feature proposal, or wether it is neither.

A scene called "Neuron.tscn" has a Sprite as scene root and a script called "Neuron.gd" attached to it; it is the only script in the scene. That script was made a class via class_name Neuron. In a separate scene and script, there are two ways to instantiate the neuron: var n = preload("res://Neuron.tscn").instance() and var n = Neuron.new(). The first way respects all editor changes I made, like setting the Sprite's texture, changing its position, etc. The second one doesn't. The "remote" tab in the scene explorer shows that the neuron instantiated via Neuron.new() has no texture and default position - in short, it has Sprite's default values.

It would be great if Object.new(), when called on user-defined classes, respected the scene overrides of default values of built-in classes.

Steps to reproduce:
Make a scene with a script attached to the root node and add class_name *name* to that script. Then try using PackedScene.instance() and Object.new() to instance the scene at runtime and compare the results.

@KoBeWi
Copy link
Member

KoBeWi commented Oct 8, 2020

This is a missing feature. When you use new() on a class name, it creates an instance of the class, not the scene. Class has no information where it's attached.

See #21187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants