prefab-user-properties-create.rst 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. .. include:: ../_header.rst
  2. Creating a prefab user property
  3. ```````````````````````````````
  4. The **Prefab Properties** section of the |InspectorView|_ shows a button to create a new user property. This section is shown when you select the scene (click on a blank space of the scene), or when you select the **Prefab Properties** element in the |OutlineView|_:
  5. .. image:: ../images/prefab-user-props-node-outline-view-20221102.webp
  6. :alt: The Prefabs Properties in the Outline view.
  7. Click on the **Add Property** button to create a new property. It opens a dialog with the different type of properties:
  8. .. image:: ../images/prefab-user-props-add-property-dialog-20230626.webp
  9. :alt: Property types dialog.
  10. .. image:: ../images/prefab-user-props-add-property-button-20230626.webp
  11. :alt: Add Property button.
  12. The properties are shown as children of the **Prefab Properties** element. Click a property for editing it in the |InspectorView|_:
  13. .. image:: ../images/prefab-user-props-as-children-outline-20221102.webp
  14. :alt: Display all properties of a prefab.
  15. All type of properties requires some common parameters that you should provide:
  16. * The **Name** of the property. It is used by the compiler to generate a property declaration code. It should be a valid JavaScript identifier.
  17. * The **Label**. It is a UI friendly version of the **Name**. For example, the label for the **maxSpeed** name could be **Maximum Speed**. In code, is generated a **maxSpeed** field, but the UI shows **Maximum Speed**.
  18. * The **Tooltip**. Used in the UI as documentation of the property.
  19. * The **Default** value.
  20. * The **Custom Definition** flag. If enabled, the |SceneCompiler|_ skips the generation of the code with the property declaration. It allows you writing a custom implementation of the property. For example, using a custom getter and setter. Learn more about `using properties with custom definition <prefab-user-properties-initializing.html#using-properties-with-custom-definition>`_.
  21. .. image:: ../images/prefab-user-props-common-params-20221102.webp
  22. :alt: Common parameters of a property.
  23. The menu of the property section shows the following actions:
  24. * Change the type of the property.
  25. * Delete the property.
  26. To change the order of the properties, go with the context menu's **Edit** |-| **Move** commands.
  27. You can undo/redo all these changes.
  28. .. image:: ../images/prefab-user-props-menu-20230627.webp
  29. :alt: Property menu.