Playing Your Game From A Text Editor

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<boo>" to "<syntaxhighlight lang="boo">")
Line 2: Line 2:
  
 
==AppleScript - Play In Unity.scpt==
 
==AppleScript - Play In Unity.scpt==
<boo>tell application "System Events"
+
<syntaxhighlight lang="boo">tell application "System Events"
 
tell application "Unity" to activate
 
tell application "Unity" to activate
 
keystroke "p" using command down
 
keystroke "p" using command down

Revision as of 20:57, 10 January 2012

When you're working in your text editor, it can be a nuisance to have to manually switch back to Unity to test your game. This AppleScript will automatically bring Unity to the front and press Command-P to start the game:

AppleScript - Play In Unity.scpt

tell application "System Events"
	tell application "Unity" to activate
	keystroke "p" using command down
end tell</boo>
 
Enter this into the AppleScript editor, save it in whatever mode your text editor supports (probably 'script'), and place it in a location where your text editor will be able to find it.
 
For example, with [http://www.barebones.com/products/bbedit/ BBEdit], save the script in ~/Library/Application Support/BBEdit/Scripts/.  Once you've done that, you can assign a keystroke to launch it using the Scripts Palette.  This also works for the free [http://www.barebones.com/products/textwrangler/ TextWrangler] editor, providing you substitute 'TextWrangler' for 'BBEdit' in the above path.
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox