diff --git a/FilterExtension/Settings.cs b/FilterExtension/Settings.cs index 373c3ac3..13f40b01 100644 --- a/FilterExtension/Settings.cs +++ b/FilterExtension/Settings.cs @@ -4,6 +4,8 @@ using System.IO; using UnityEngine; using UnityEngine.UI; +using UnityEngine.Events; +using UnityEngine.EventSystems; namespace FilterExtensions { @@ -16,9 +18,9 @@ class Settings : MonoBehaviour { static Canvas settingsCanvasPrefab; static Canvas windowInstance; + RectTransform windowPosition; + - Rect settingsRect = new Rect(Screen.width / 2, Screen.height / 2, 400, 0); - static bool showWindow; private static ApplicationLauncherButton btnLauncher; public const string RelativeSettingsPath = "GameData/000_FilterExtensions/PluginData/"; @@ -32,7 +34,6 @@ class Settings : MonoBehaviour public void Start() { - showWindow = false; if (btnLauncher == null) btnLauncher = ApplicationLauncher.Instance.AddModApplication(toggleSettingsVisible, toggleSettingsVisible, null, null, null, null, ApplicationLauncher.AppScenes.SPACECENTER, @@ -123,6 +124,13 @@ static void toggleSettingsVisible() private void InstantiateCanvas() { windowInstance = Instantiate(settingsCanvasPrefab); + windowPosition = windowInstance.transform.GetChild(0) as RectTransform; // windowInstance.gameObject.GetChild("Panel"); + EventTrigger.Entry entry = new EventTrigger.Entry(); + entry.eventID = EventTriggerType.Drag; + entry.callback = new EventTrigger.TriggerEvent(); + entry.callback.AddListener((x) => windowDrag(x)); + windowPosition.gameObject.GetComponent().triggers.Add(entry); + Toggle[] boolSettings = windowInstance.GetComponentsInChildren(); foreach (Toggle t in boolSettings) @@ -193,5 +201,10 @@ public void subCat_txtInputChanged(string newValue) { Settings.subCategoryDefault = newValue; } + + public void windowDrag(UnityEngine.EventSystems.BaseEventData data) + { + windowPosition.position += new Vector3(((PointerEventData)data).delta.x, ((PointerEventData)data).delta.y); + } } } diff --git a/GameData/000_FilterExtensions/FilterExtensions.dll b/GameData/000_FilterExtensions/FilterExtensions.dll index f8b5282b..74c8dc0d 100644 Binary files a/GameData/000_FilterExtensions/FilterExtensions.dll and b/GameData/000_FilterExtensions/FilterExtensions.dll differ diff --git a/GameData/000_FilterExtensions/fesettings.ksp b/GameData/000_FilterExtensions/fesettings.ksp index 6ba5d26e..135ddcf5 100644 Binary files a/GameData/000_FilterExtensions/fesettings.ksp and b/GameData/000_FilterExtensions/fesettings.ksp differ