Skip to content

Commit

Permalink
Exporting
Browse files Browse the repository at this point in the history
- Added script for exporting the package.
- Updated some tooltips.
  • Loading branch information
Jan Discart committed Sep 4, 2021
1 parent 63b5488 commit 1112196
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Assets/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions Assets/Editor/ExportMouseEventsPackage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.IO;
using UnityEngine;
using UnityEditor;

public static class ExportMouseEventsPackage
{
private const string ExportPackageDirectoryKey = "ImpossibleOdds_Export_Path";
private const string ExportPackageNameKey = "ImpossibleOdds_Export_MouseEvents_Filename";

private const string PackageExtension = "unitypackage";

[MenuItem("Assets/Impossible Odds/Export/Mouse Events")]
private static void ExportToolkit()
{
string path = EditorPrefs.GetString(ExportPackageDirectoryKey, Application.dataPath);
string name = EditorPrefs.GetString(ExportPackageNameKey, "Impossible Odds Mouse Events");
string fullPath = EditorUtility.SaveFilePanel("Export Impossible Odds Mouse Events", path, name, PackageExtension);

if (string.IsNullOrEmpty(fullPath))
{
return;
}

FileInfo fileInfo = new FileInfo(fullPath);
path = fileInfo.DirectoryName;
name = Path.GetFileNameWithoutExtension(fileInfo.Name);
EditorPrefs.SetString(ExportPackageDirectoryKey, path);
EditorPrefs.SetString(ExportPackageNameKey, name);

AssetDatabase.ExportPackage("Assets/Impossible Odds", fullPath, ExportPackageOptions.Recurse);
}
}
11 changes: 11 additions & 0 deletions Assets/Editor/ExportMouseEventsPackage.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public class MouseEventMonitor : MonoBehaviour
/// </summary>
public event Action<MouseButtonEvent> onDragCompleted;

[SerializeField, Tooltip("Which mouse button should be monitored?")]
[SerializeField, Tooltip("Which mouse buttons should be monitored?")]
private List<MouseButton> monitoredButtons = new List<MouseButton>();
[SerializeField, Tooltip("How long should it wait to register a multi-click?"), Range(0.1f, 1f)]
[SerializeField, Tooltip("How long (in seconds) should it wait for registering a multi-click event?"), Range(0.1f, 1f)]
private float multiClickTimeTreshold = 0.2f;

private Dictionary<MouseButton, MouseButtonStateTracker> stateTrackers = new Dictionary<MouseButton, MouseButtonStateTracker>();
Expand Down Expand Up @@ -114,7 +114,7 @@ public void StopMonitoring(MouseButton mouseButton)
if (IsMonitored(mouseButton))
{
stateTrackers.Remove(mouseButton);
monitoredButtons.Remove(mouseButton);
monitoredButtons.RemoveAll(mB => mB == mouseButton);
}
}

Expand Down

0 comments on commit 1112196

Please sign in to comment.