public static OpenBrowser ( AirConsole controller, string startUpPath ) : void | ||
controller | AirConsole | |
startUpPath | string | |
리턴 | void |
public static void OpenBrowser (AirConsole controller, string startUpPath) {
// set the root path for webserver
webserver.SetPath (startUpPath);
webserver.Start ();
if (controller != null && controller.enabled) {
if (controller.controllerHtml != null) {
string sourcePath = Path.Combine (Directory.GetCurrentDirectory (), AssetDatabase.GetAssetPath (controller.controllerHtml));
string targetPath = Path.Combine (Directory.GetCurrentDirectory (), "Assets" + Settings.WEBTEMPLATE_PATH + "/controller.html");
// rename index.html to screen.html
File.Copy (sourcePath, targetPath, true);
if (controller.browserStartMode != StartMode.NoBrowserStart) {
string url = AirConsole.GetUrl (controller.browserStartMode) + "http://" + GetLocalAddress () + ":" + Settings.webServerPort + "/";
// add port info if starting the unity editor version
if (startUpPath.Contains (Settings.WEBTEMPLATE_PATH)) {
url += "?unity-editor-websocket-port=" + Settings.webSocketPort + "&unity-plugin-version=" + Settings.VERSION;
}
Application.OpenURL (url);
} else {
AirConsole.instance.ProcessJS ("{action:\"onReady\", code:\"0\", devices:[], server_time_offset: 0, device_id: 0, location: \"\" }");
}
} else {
EditorUtility.DisplayDialog ("AirController", "Please link a controller file to the AirController object.", "ok");
Debug.Break ();
}
}
}
public override void OnInspectorGUI() { controller = (AirConsole)target; // show logo & version EditorGUILayout.BeginHorizontal(styleBlack, GUILayout.Height(30)); GUILayout.Label(logo, GUILayout.Width(128), GUILayout.Height(30)); GUILayout.FlexibleSpace(); GUILayout.Label("v" + Settings.VERSION, styleBlack); EditorGUILayout.EndHorizontal(); // show default inspector property editor withouth script reference serializedObject.Update(); DrawPropertiesExcluding(serializedObject, new string[] { "m_Script" }); serializedObject.ApplyModifiedProperties(); //translation bool bool oldTranslationValue = translationValue; translationValue = EditorGUILayout.Toggle("Translation", translationValue); if (oldTranslationValue != translationValue) { string path = Application.dataPath + Settings.WEBTEMPLATE_PATH + "/translation.js"; if (translationValue) { System.IO.File.WriteAllText(path, TRANSLATION_ACTIVE); } else { System.IO.File.WriteAllText(path, TRANSLATION_INACTIVE); } } EditorGUILayout.BeginHorizontal(styleBlack); // check if a port was exported if (System.IO.File.Exists(EditorPrefs.GetString("airconsolePortPath") + "/screen.html")) { if (GUILayout.Button("Open Exported Port", GUILayout.MaxWidth(130))) { Extentions.OpenBrowser(controller, EditorPrefs.GetString("airconsolePortPath")); } } GUILayout.FlexibleSpace(); if (GUILayout.Button("Settings")) { SettingWindow window = (SettingWindow)EditorWindow.GetWindow(typeof(SettingWindow)); window.Show(); } EditorGUILayout.EndHorizontal(); }