You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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()
andvar 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 viaNeuron.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 usingPackedScene.instance()
andObject.new()
to instance the scene at runtime and compare the results.The text was updated successfully, but these errors were encountered: