Fix Function Popup Menu in Unitron

From Unify Community Wiki
Jump to: navigation, search

If you're like me and you like your code as explicit as possible, you'll find that if you prefix UnityScript function definitions with public, protected or private scope specifiers they'll no longer be recognized by Untiron's function pop-up making it tedious to code. This is because javascript doesn't support scoped functions but UnityScript does.

I'm no regular expression expert, but I found a way to modify Unitron so it will correctly find functions that are explicitly declared.

PROCEED AT YOUR OWN RISK.

  1. Navigate to Unitron.app, right click and choose Open Package.
  2. In the window that opens, navigate to Contents:Resources:Syntax Definitions and open javascript.plist (should open with Property List Editor)
  3. Find the key functionDefinition and change the value from ^\s*function\s+.*\n?\s*{ to one of the following:
    • ^\s*(static|public|protected|private|function)\s*\s+.*\n?\s*{
    • ^\s*(static|public|protected|private)\s*function\s+.*\n?\s*{
  4. Save and relaunch Unitron (if it was already open).
  5. Open a script and test that it's working.

The difference between the two above is that the first one shows functions declared without scope whereas the second one will only show those functions explicitly declared. The first version is recommended if you use Unitron to edit proper javascript files as otherwise you won't see your functions (because javascript doesn't support scoped functions).

NOTE: CAREFUL IF YOU COPY AND PASTE THE EXPRESSIONS ABOVE, BE SURE TO REMOVE ANY CHARACTER AFTER THE "{" AT THE END AFTER YOU PASTE IT INTO THE VALUE FIELD OTHERWISE IT WON'T WORK

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Tools