prefab-user-properties-object-variable-type.rst 963 B

1234567891011121314151617181920212223242526272829
  1. .. include:: ../_header.rst
  2. Object Variable property type
  3. `````````````````````````````
  4. This user property type is dedicated for referencing objects in the scene. It provides a dialog for selecting an object in the scene and sets as value of the property, the name of the variable referencig the object:
  5. .. image:: ../images/prefab-user-props-object-variable-20220409.webp
  6. :alt: The object reference editor.
  7. This property type if a subset of the `Expression property type <./prefab-user-properties-expression-type.html>`_. You can define the type of the property. By default, it is ``Phaser.GameObjects.Game``, but you can write any other type.
  8. .. code::
  9. class Eagle extends Phaser.GameObjects.Sprite {
  10. ...
  11. /** @type {Phaser.GameObjects.GameObject} */
  12. attackTarget;
  13. }
  14. The value set to this property is is verbatim-copied to the generated code:
  15. .. code::
  16. // eagle (prefab fields)
  17. eagle.attackTarget = player;