2022-04-14 19:18:44 +08:00
using Assets.Scripts ;
using System.Collections ;
2022-03-10 18:10:34 +08:00
using System.Collections.Generic ;
using UnityEngine ;
2022-06-14 18:37:58 +08:00
using UnityEngine.Android ;
2022-03-10 18:10:34 +08:00
using UnityEngine.UI ;
public class RowerDevicePanel : PFUIPanel
{
protected override void Awake ( )
{
UIManager . AddEvent ( transform . Find ( "Container/Tools/Back" ) . gameObject , UnityEngine . EventSystems . EventTriggerType . PointerClick , b = >
{
2022-06-08 13:05:56 +08:00
App . MainDeviceAdapter . StopScan ( ) ;
2022-03-10 18:10:34 +08:00
Close ( ) ;
} ) ;
}
// Start is called before the first frame update
void Start ( )
{
2022-04-14 19:18:44 +08:00
}
public override void Show ( )
{
base . Show ( ) ;
print ( "开启扫描" ) ;
#if UNITY_ANDROID | | UNITY_IOS
#if UNITY_ANDROID
Utils . CallAndroidMethod ( "OpenLocationService" ) ;
2022-06-14 18:37:58 +08:00
if ( ! Permission . HasUserAuthorizedPermission ( Permission . CoarseLocation ) )
{
Permission . RequestUserPermission ( Permission . CoarseLocation ) ;
Permission . RequestUserPermission ( Permission . FineLocation ) ;
UIManager . ShowConfirm ( App . GetLocalString ( "Warning" ) , App . GetLocalString ( "Powerfun need location service permission,please open the location permission." )
, ( ) = > {
UIManager . CloseConfirm ( ) ;
} , 2
, ( ) = > {
UIManager . CloseConfirm ( ) ;
} ) ;
}
2022-04-14 19:18:44 +08:00
#endif
2022-06-09 14:51:03 +08:00
App . MainDeviceAdapter . StartScan ( ) ;
2022-04-14 19:18:44 +08:00
#endif
2022-03-10 18:10:34 +08:00
}
float timer = 1f ;
// Update is called once per frame
void Update ( )
{
timer - = Time . deltaTime ;
if ( timer < = 0 )
{
if ( App . MainDeviceAdapter . GetState ( Assets . Scripts . Devices . ConnectionInterface . BLE ) = = Assets . Scripts . Devices . DeviceAdapterState . On )
{
transform . Find ( "Container/Tools/BlueTooth" ) . GetComponent < Image > ( ) . sprite = Resources . Load < Sprite > ( "Images/RowerNew/ICON_bluetooth_44_on" ) ;
}
else
{
transform . Find ( "Container/Tools/BlueTooth" ) . GetComponent < Image > ( ) . sprite = Resources . Load < Sprite > ( "Images/RowerNew/ICON_bluetooth_44" ) ;
}
timer + = 1f ;
}
}
2022-06-09 14:51:03 +08:00
protected override void OnDisable ( )
{
App . MainDeviceAdapter . StopScan ( ) ;
}
protected override void OnDestroy ( )
{
App . MainDeviceAdapter . StopScan ( ) ;
}
2022-03-10 18:10:34 +08:00
}