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 referenz serializedObject.Update (); DrawPropertiesExcluding (serializedObject, new string[] { "m_Script" }); serializedObject.ApplyModifiedProperties (); 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 (); }
public static void OnPlayModeStateChanged(PlayModeState currentMode, PlayModeState changedMode) { if (currentMode == PlayModeState.Stopped && changedMode == PlayModeState.Playing || currentMode == PlayModeState.AboutToPlay && changedMode == PlayModeState.Playing) { AirConsole controller = GameObject.FindObjectOfType <AirConsole>(); OpenBrowser(controller, Application.dataPath + Settings.WEBTEMPLATE_PATH); } }
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(); }
// Use this for initialization void Start() { airConsole = new AirConsole(); Score = 0; timesPressed = 0; AirConsole.instance.onMessage += OnMessage; JumpVector = new Vector3(0, 8, 0); gameObject.AddComponent <Rigidbody>(); rb = gameObject.GetComponent <Rigidbody>(); //rb.velocity = JumpVector; InitAudioDictionary(); rb.useGravity = false; pipeFactRef = GameObject.Find("PipeFactory").GetComponent <PipeObjectFactory>(); }
static void CreateAirController() { AirConsole airConsole = GameObject.FindObjectOfType <AirConsole>(); if (airConsole == null) { GameObject _tmp = new GameObject("AirConsole"); _tmp.AddComponent <AirConsole>(); } else { EditorUtility.DisplayDialog("Already exists", "AirController object already exists in the current scene", "ok"); EditorGUIUtility.PingObject(airConsole.GetInstanceID()); } }
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 referenz serializedObject.Update(); DrawPropertiesExcluding(serializedObject, new string[] { "m_Script" }); serializedObject.ApplyModifiedProperties(); 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(); }
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=1.3.0.c"; } 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(); } } }