Script assets are edited using PlayCanvas' Code Editor. Double click on a script asset to open the file in the Editor. The Editor supports real-time collaborative editing by all users with permission to edit the code. You will see other user's avatars in the bottom right of the code editor window
Collaboration, Saving & Reverting
The code editor is collaborative which means that every user who has the document open in the editor will see changes as they are made by other developers. However, changes are not saved automatically and when the application is run from the Editor the saved version is loaded. This means you can choose at which point to commit your change to be used by the application. Any user can save the document at any time. The Revert button will restore the document back to the last saved version. If all users exit the document before saving the unsaved changes will be preserved for a short time before the document is automatically reverted to the saved version. So you should save your work before exiting the document.
|Undo||Ctrl + Z||Cmd + Z|
|Redo||Ctrl + Y||Cmd + Shift + Z or Cmd + Y|
|Find in file||Ctrl + F||Cmd + F|
|Find next match||Ctrl + G||Cmd + G|
|Find previous match||Ctrl + Shift + G||Cmd + Shift + G|
|Replace||Ctrl + Shift + F||Cmd + Alt + F|
|Replace all||Ctrl + Shift + R||Cmd + Shift + Alt + F|
|Rename variable||Ctrl + Q||Ctrl + Q|
|Comment line or selection||Ctrl + /||Cmd + /|
|Indent line or selection||Ctrl + [||Cmd + [|
|Un-Indent line or selection||Ctrl + ]||Cmd + ]|
|Auto indent line or selection||Ctrl + I||Cmd + I|
|Jump to declaration||Alt + .||Alt + .|
|Show autocomplete||Ctrl + Space||Ctrl + Space|
|Show documentation||Ctrl + O||Cmd + O|
Highlighting a word in the code editor will highlight all other matches in the file which makes it easier to check where a variable or function is being used.
Use Regex for Searching
By default, the search feature is case insensitive and matches any part of a word. Regular expressions (regex) can be used to make more specific matches.
Common regex patterns are (using the word 'position' for all examples):
|Case sensitive||/position/||Matches 'position' and 'getposition'. Doesn't match 'Position' or 'getPosition'.|
|Case insensitive||/position/i||Matches 'position', 'getposition', 'Position' and 'getPosition'.|
|Whole word (case sensitive)||/\bposition\b/||Matches 'position'. Doesn't match 'Position' or 'getPosition'.|
|Whole word (case insensitive)||/\bposition\b/i||Matches 'position' and 'Position'. Doesn't match 'getPosition'.|
If you would like to learn and experiment more with regex, then RegExr is great site with cheatsheets, examples and an online editor for testing regex expressions.
Multiple Selection Editing
Holding down Ctrl (PC) or Cmd (Mac) and clicking left mouse button will add another cursor to the editor. This allows you to quickly make the same changes in multiple areas of the file.
Holding down Alt and dragging left mouse button will create a rectangular selection which is useful for selecting and editing columns of text.