示例#1
0
        /// <summary>
        /// Inspector GUI draw call.
        /// </summary>
        public override void OnInspectorGUI()
        {
            // Draw serialized properties
            serializedObject.Update();

            // Browser start mode and canvas scale settings
            tempBrowserStart    = (int)(BrowserStartMode)EditorGUILayout.EnumPopup("Browser Start", (BrowserStartMode)Config.BrowserStart);
            tempAutoScaleCanvas = EditorGUILayout.Toggle("Auto Scale Canvas", Config.AutoScaleCanvas);

            // Do not show this script in inspector
            DrawPropertiesExcluding(serializedObject, excludedProperties);

            serializedObject.ApplyModifiedProperties();

            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            // Controller list popup
            tempSelectedController = controllerList[EditorGUILayout.Popup("Controller",
                                                                          Array.IndexOf <string>(controllerList, tempSelectedController),
                                                                          controllerList)];

            // Store those settings in editor preferences
            if (tempBrowserStart != Config.BrowserStart)
            {
                Config.BrowserStart = tempBrowserStart;
                EditorPrefs.SetInt("BrowserStart", tempBrowserStart);
            }

            if (tempAutoScaleCanvas != Config.AutoScaleCanvas)
            {
                Config.AutoScaleCanvas = tempAutoScaleCanvas;
                EditorPrefs.SetBool("AutoScaleCanvas", tempAutoScaleCanvas);
            }

            // Current controller changed
            if (tempSelectedController != Config.SelectedController)
            {
                // Reload controller data
                ReloadControllerData();
            }

            // Controller Editor
            // Delete controller
            if ((Config.SelectedController != null) && (Config.SelectedController.Length > 0))
            {
                if (GUILayout.Button("Open Controller Editor"))
                {
                    Application.OpenURL(String.Format("http://localhost:{0:D}/volplane/controller-editor.html?controller={1:G}",
                                                      Config.LocalServerPort,
                                                      Config.SelectedController));
                }

                if (GUILayout.Button("Delete Current Controller"))
                {
                    if (EditorUtility.DisplayDialog("Delete Controller",
                                                    "Are you sure you want to delete this controller?",
                                                    "Yes",
                                                    "No"))
                    {
                        string controllerPath = controllerPaths[Array.IndexOf <string>(controllerList, tempSelectedController) - 1];

                        // Delete controller
                        if (File.Exists(controllerPath))
                        {
                            File.Delete(controllerPath);
                        }

                        if (File.Exists(controllerPath + ".meta"))
                        {
                            File.Delete(controllerPath + ".meta");
                        }

                        // Reload controller list, image-, font- and controller data
                        // Reload controller data
                        ReloadControllerList();
                        ReloadControllerData();
                    }
                }
            }

            // Add new controller
            if (GUILayout.Button("Add New Controller"))
            {
                NewControllerWindow.Init();

                // Subscribe controller created event
                NewControllerWindow.window.ControllerCreated -= OnControllerCreated;
                NewControllerWindow.window.ControllerCreated += OnControllerCreated;
            }

            // Check if there is a builded version
            if (File.Exists(EditorPrefs.GetString("BuildPath") + "/screen.html"))
            {
                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

                // Open last build
                if (GUILayout.Button("Open Last Build"))
                {
                    Volplane.Editor.Extensions.OpenBuild();
                }
            }

            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            // Show version info, license, etc...
            EditorGUILayout.SelectableLabel(
                String.Format("Volplane Framework {0:G}\n" +
                              "Licensed under the GNU GPL v3\n\n" +
                              "Source and more license information on GitHub: {1:G}\n" +
                              "Designed for AirConsole: {2:G}", Config.Version, Config.VolplaneUrl, Config.AirConsoleUrl),
                infoTextStyle,
                GUILayout.Height(60f)
                );
        }
示例#2
0
        /// <summary>
        /// Init this instance.
        /// </summary>
        public static void Init()
        {
            Rect position = new Rect(400f, 400f, 400f, 140f);

            NewControllerWindow.window = EditorWindow.GetWindowWithRect <NewControllerWindow>(position, true, "Create New Controller", true);
        }