Esempio n. 1
0
        public static void OpenBrowser(NDream.AirConsole.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();
                }
            }
        }
Esempio n. 2
0
        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();
        }