Skip to main content

Scripting for Editor Users

This section focuses on the Editor-specific features and best practices that will enhance your scripting experience. Whether you're writing your first line of code or you're a seasoned developer, understanding these tools will significantly boost your productivity.

Why This Section is Important for Editor Users

As an Editor user, you benefit from a tightly integrated development environment. This means:

  • Direct Asset Management: Scripts are assets, managed alongside your models, textures, and materials.
  • Visual Configuration: Script Attributes allow for easy, code-free customization of script behavior directly in the Inspector.
  • Rapid Iteration: Features like Hot Reloading let you see changes in real-time.
  • Seamless Integration: The Editor bridges the gap between your code and your scene, making it easy to connect scripts to Entities and Components.

What You'll Discover Here

This collection of pages will delve into the tools and techniques unique to scripting within the PlayCanvas Editor:

  • Managing Scripts in the Editor:
    • Creating, organizing, and deleting Script Assets in the Asset panel.
    • Understanding the connection between Script Assets (.js/.mjs files) and Script Components (instances on Entities).
    • Renaming and moving scripts, and how the Editor handles references.
  • The Built-in Code Editor:
    • Navigating and using the Editor's integrated code editing interface.
    • Key features: syntax highlighting, autocompletion (basic), error checking, and search.
    • Tips for efficient coding directly within PlayCanvas.
  • Using VS Code with PlayCanvas:
    • Setting up and using the official PlayCanvas VS Code Extension.
    • Benefits: advanced autocompletion, debugging, richer IntelliSense, and project-wide search.
    • Synchronizing changes between VS Code and the PlayCanvas Editor.
  • Script Attributes in the Editor:
    • How Script Attributes appear and are managed in the Inspector panel.
    • Assigning various asset types (Entities, Assets, Materials, etc.) to attributes.
    • Leveraging arrays and nested attributes for complex configurations.
  • Script Hot Reloading:
    • Understanding how Hot Reloading works and its benefits for rapid iteration.
    • What gets reloaded and what doesn't (initialize vs. swap).
    • Tips for writing scripts that work well with Hot Reloading.

Unlocking the Editor's Power

By familiarizing yourself with these Editor-specific aspects of scripting, you'll be able to work more efficiently and build more complex and robust interactive experiences. Each page linked above will provide detailed information and practical guidance.