-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
Develop
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#if UNITY_EDITOR || UNITY_ANDROID | ||
using UnityEngine; | ||
|
||
namespace SimpleFileBrowser | ||
{ | ||
public class FBCallbackHelper : MonoBehaviour | ||
{ | ||
private System.Action mainThreadAction = null; | ||
|
||
private void Awake() | ||
{ | ||
DontDestroyOnLoad( gameObject ); | ||
} | ||
|
||
private void Update() | ||
{ | ||
if( mainThreadAction != null ) | ||
{ | ||
System.Action temp = mainThreadAction; | ||
mainThreadAction = null; | ||
temp(); | ||
} | ||
} | ||
|
||
public void CallOnMainThread( System.Action function ) | ||
{ | ||
mainThreadAction = function; | ||
} | ||
} | ||
} | ||
#endif |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#if UNITY_EDITOR || UNITY_ANDROID | ||
using UnityEngine; | ||
|
||
namespace SimpleFileBrowser | ||
{ | ||
public class FBDirectoryReceiveCallbackAndroid : AndroidJavaProxy | ||
{ | ||
private readonly FileBrowser.AndroidSAFDirectoryPickCallback callback; | ||
private readonly FBCallbackHelper callbackHelper; | ||
|
||
public FBDirectoryReceiveCallbackAndroid( FileBrowser.AndroidSAFDirectoryPickCallback callback ) : base( "com.yasirkula.unity.FileBrowserDirectoryReceiver" ) | ||
{ | ||
this.callback = callback; | ||
callbackHelper = new GameObject( "FBCallbackHelper" ).AddComponent<FBCallbackHelper>(); | ||
} | ||
|
||
public void OnDirectoryPicked( string rawUri, string name ) | ||
{ | ||
callbackHelper.CallOnMainThread( () => DirectoryPickedCallback( rawUri, name ) ); | ||
} | ||
|
||
private void DirectoryPickedCallback( string rawUri, string name ) | ||
{ | ||
try | ||
{ | ||
if( callback != null ) | ||
callback( rawUri, name ); | ||
} | ||
finally | ||
{ | ||
Object.Destroy( callbackHelper.gameObject ); | ||
} | ||
} | ||
} | ||
} | ||
#endif |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#if UNITY_EDITOR || UNITY_ANDROID | ||
using System.Threading; | ||
using UnityEngine; | ||
|
||
namespace SimpleFileBrowser | ||
{ | ||
public class FBPermissionCallbackAndroid : AndroidJavaProxy | ||
{ | ||
private object threadLock; | ||
public int Result { get; private set; } | ||
|
||
public FBPermissionCallbackAndroid( object threadLock ) : base( "com.yasirkula.unity.FileBrowserPermissionReceiver" ) | ||
{ | ||
Result = -1; | ||
this.threadLock = threadLock; | ||
} | ||
|
||
public void OnPermissionResult( int result ) | ||
{ | ||
Result = result; | ||
|
||
lock( threadLock ) | ||
{ | ||
Monitor.Pulse( threadLock ); | ||
} | ||
} | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.