Skip to content

Commit

Permalink
New Input System no longer requires any manual modifications (closed #55
Browse files Browse the repository at this point in the history
)
  • Loading branch information
yasirkula committed Sep 30, 2023
1 parent 28c046d commit 6d57445
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
19 changes: 9 additions & 10 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ There are 5 ways to install this plugin:
- *(via [OpenUPM](https://openupm.com))* after installing [openupm-cli](https://github.com/openupm/openupm-cli), run the following command:
- `openupm add com.yasirkula.simplefilebrowser`

### NEW INPUT SYSTEM SUPPORT

This plugin supports Unity's new Input System but it requires some manual modifications (if both the legacy and the new input systems are active at the same time, no changes are needed):

- the plugin mustn't be installed as a package, i.e. it must reside inside the *Assets* folder and not the *Packages* folder (it can reside inside a subfolder of Assets like *Assets/Plugins*)
- if Unity 2019.2.5 or earlier is used, add `ENABLE_INPUT_SYSTEM` compiler directive to **Player Settings/Scripting Define Symbols** (these symbols are platform specific, so if you change the active platform later, you'll have to add the compiler directive again)
- add `Unity.InputSystem` assembly to **SimpleFileBrowser.Runtime** Assembly Definition File's *Assembly Definition References* list
- open *SimpleFileBrowserCanvas* prefab, select *EventSystem* child object and replace *StandaloneInputModule* component with *InputSystemUIInputModule* component (or, if your scene(s) already have EventSystem objects, you can delete SimpleFileBrowserCanvas prefab's EventSystem child object)

## FAQ

- **File browser doesn't show any files on Mac when sandboxing is enabled**
Expand All @@ -54,7 +45,7 @@ This is a known issue but I can't give an ETA for a solution at the moment: http

- **File browser doesn't show any files on Android 10+**

File browser uses *Storage Access Framework* on these Android versions and users must first click the *Browse...* button in the quick links section
File browser uses *Storage Access Framework* on these Android versions and users must first click the *Browse...* button in the quick links section.

- **File browser doesn't show any files on Oculus Quest**

Expand All @@ -64,6 +55,14 @@ Please see: https://github.com/yasirkula/UnitySimpleFileBrowser/issues/87

Please see: https://github.com/yasirkula/UnitySimpleFileBrowser/issues/70

- **New Input System isn't supported on Unity 2019.2.5 or earlier**

Add `ENABLE_INPUT_SYSTEM` compiler directive to **Player Settings/Scripting Define Symbols** (these symbols are platform specific, so if you change the active platform later, you'll have to add the compiler directive again).

- **"Unity.InputSystem" assembly can't be resolved on Unity 2018.4 or earlier**

Remove `Unity.InputSystem` assembly from **SimpleFileBrowser.Runtime** Assembly Definition File's *Assembly Definition References* list.

- **Android build fails, it says "error: attribute android:requestLegacyExternalStorage not found" in Console**

`android:requestLegacyExternalStorage` attribute in _AndroidManifest.xml_ grants full access to device's storage on Android 10 but requires you to update your Android SDK to at least **SDK 29**. If this isn't possible for you, you should open *SimpleFileBrowser.aar* with WinRAR or 7-Zip and then remove the `<application ... />` tag from _AndroidManifest.xml_.
Expand Down
9 changes: 0 additions & 9 deletions Plugins/SimpleFileBrowser/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ File browser comes bundled with two premade skins in the Skins directory: LightS
- By changing the value of FileBrowser.Skin property from a C# script


### NEW INPUT SYSTEM SUPPORT
This plugin supports Unity's new Input System but it requires some manual modifications (if both the legacy and the new input systems are active at the same time, no changes are needed):

- the plugin mustn't be installed as a package, i.e. it must reside inside the Assets folder and not the Packages folder (it can reside inside a subfolder of Assets like Assets/Plugins)
- if Unity 2019.2.5 or earlier is used, add ENABLE_INPUT_SYSTEM compiler directive to "Player Settings/Scripting Define Symbols" (these symbols are platform specific, so if you change the active platform later, you'll have to add the compiler directive again)
- add "Unity.InputSystem" assembly to "SimpleFileBrowser.Runtime" Assembly Definition File's "Assembly Definition References" list
- open SimpleFileBrowserCanvas prefab, select EventSystem child object and replace StandaloneInputModule component with InputSystemUIInputModule component (or, if your scene(s) already have EventSystem objects, you can delete SimpleFileBrowserCanvas prefab's EventSystem child object)


### FAQ
- Android build fails, it says "error: attribute android:requestLegacyExternalStorage not found" in Console
"android:requestLegacyExternalStorage" attribute in AndroidManifest.xml grants full access to device's storage on Android 10 but requires you to update your Android SDK to at least SDK 29. If this isn't possible for you, you should open SimpleFileBrowser.aar with WinRAR or 7-Zip and then remove the "<application ... />" tag from AndroidManifest.xml.
Expand Down
15 changes: 15 additions & 0 deletions Plugins/SimpleFileBrowser/Scripts/EventSystemHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
using UnityEngine.InputSystem.UI;
#endif

namespace SimpleFileBrowser
{
Expand All @@ -13,6 +16,18 @@ public class EventSystemHandler : MonoBehaviour
private GameObject embeddedEventSystem;
#pragma warning restore 0649

#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
private void Awake()
{
StandaloneInputModule legacyInputModule = embeddedEventSystem.GetComponent<StandaloneInputModule>();
if( legacyInputModule )
{
DestroyImmediate( legacyInputModule );
embeddedEventSystem.AddComponent<InputSystemUIInputModule>();
}
}
#endif

private void OnEnable()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
Expand Down
7 changes: 5 additions & 2 deletions Plugins/SimpleFileBrowser/SimpleFileBrowser.Runtime.asmdef
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"name": "SimpleFileBrowser.Runtime"
}
"name": "SimpleFileBrowser.Runtime",
"references": [
"Unity.InputSystem"
]
}

0 comments on commit 6d57445

Please sign in to comment.