-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathUnity3DScriptReference.py
More file actions
55 lines (43 loc) · 1.89 KB
/
Unity3DScriptReference.py
File metadata and controls
55 lines (43 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# written by Jacob Pennock (www.jacobpennock.com)
# based on WordPress Codex Search Plugin by Matthias Krok (www.welovewordpress.de)
# available commands
# unity_reference_open_selection
# unity_reference_search_selection
# unity_reference_search_from_input
import sublime
import sublime_plugin
import subprocess
import webbrowser
def SearchUnityScriptReferenceFor(text):
url = 'http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=' + text.replace(' ','%20')
webbrowser.open_new_tab(url)
def OpenUnityFunctionReference(text):
url = 'http://unity3d.com/support/documentation/ScriptReference/' + text.replace(' ','%20')
webbrowser.open_new_tab(url)
class UnityReferenceOpenSelectionCommand(sublime_plugin.TextCommand):
def run(self, edit):
for selection in self.view.sel():
# if the user didn't select anything, search the currently highlighted word
if selection.empty():
selection = self.view.word(selection)
text = self.view.substr(selection)
OpenUnityFunctionReference(text)
class UnityReferenceSearchSelectionCommand(sublime_plugin.TextCommand):
def run(self, edit):
for selection in self.view.sel():
# if the user didn't select anything, search the currently highlighted word
if selection.empty():
selection = self.view.word(selection)
text = self.view.substr(selection)
SearchUnityScriptReferenceFor(text)
class UnityReferenceSearchFromInputCommand(sublime_plugin.WindowCommand):
def run(self):
# Get the search item
self.window.show_input_panel('Search Unity Refference for', '',
self.on_done, self.on_change, self.on_cancel)
def on_done(self, input):
SearchUnityScriptReferenceFor(input)
def on_change(self, input):
pass
def on_cancel(self):
pass