Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

Commit

Permalink
drag window
Browse files Browse the repository at this point in the history
  • Loading branch information
Crzyrndm committed May 13, 2016
1 parent 5885b2a commit fac176a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions FilterExtension/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using UnityEngine.EventSystems;

namespace FilterExtensions
{
Expand All @@ -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/";
Expand All @@ -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,
Expand Down Expand Up @@ -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<EventTrigger>().triggers.Add(entry);


Toggle[] boolSettings = windowInstance.GetComponentsInChildren<Toggle>();
foreach (Toggle t in boolSettings)
Expand Down Expand Up @@ -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);
}
}
}
Binary file modified GameData/000_FilterExtensions/FilterExtensions.dll
Binary file not shown.
Binary file modified GameData/000_FilterExtensions/fesettings.ksp
Binary file not shown.

0 comments on commit fac176a

Please sign in to comment.