支持蓝牙可用状态变更。搜索不到设备自动停止当前线程。
This commit is contained in:
1 parent
dd474f1f61
commit
734893ff83
27 files changed
+290
-143
No files matched your search
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Scenes
|
||||
{
|
||||
public abstract class BaseScene: MonoBehaviour
|
||||
{
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Debug.Log("base scene awake");
|
||||
Application.logMessageReceived += Application_logMessageReceived;
|
||||
}
|
||||
|
||||
private void Application_logMessageReceived(string condition, string stackTrace, LogType type)
|
||||
{
|
||||
//Debug.Log("application log");
|
||||
if (type == LogType.Error || type == LogType.Exception)
|
||||
{
|
||||
string log = $"time:{ System.DateTime.Now.ToString() }\r\n";
|
||||
log += $"type:{ type }\r\n";
|
||||
log += $"msg:{ condition }\r\n";
|
||||
log += $"stack trace:{ stackTrace }\r\n";
|
||||
System.IO.File.AppendAllText($"{PFConstants.LogFolder}\\{ System.DateTime.Now.ToString("yyyy-MM-dd") }.txt", log);
|
||||
|
||||
//Debug.Log(PFConstants.LogFolder);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
App.MainDeviceAdapter.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e959496c1867434a9491c1416cb1c68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,6 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Devices.Ant;
|
||||
using Assets.Scripts.Scenes;
|
||||
using Assets.Scripts.UI.Prefab.Device;
|
||||
using Mapbox.Examples;
|
||||
using System.Collections;
|
||||
@@ -8,32 +9,20 @@ using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MainController : MonoBehaviour
|
||||
public class MainController : BaseScene
|
||||
{
|
||||
[SerializeField]GameObject root;
|
||||
private Text Version;
|
||||
private void Awake()
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
Version = this.transform.Find("GameObject").Find("Version").GetComponent<Text>();
|
||||
Version.text = "V"+App.AppVersion;
|
||||
DeviceCache.Init(PFConstants.DeviceCacheFolder);
|
||||
Loom.Initialize();
|
||||
//AntConnector.Instance((device2) => {
|
||||
// if (device2.State == DeviceState.Disconnected)
|
||||
// {
|
||||
// //Debug.Log($"探索到新的设备{ device2.DeviceNumber }");
|
||||
// //自动连接
|
||||
// if (DeviceCache.Exist(device2))
|
||||
// {
|
||||
// Debug.Log("自动连接" + device2.DeviceNumber);
|
||||
// device2.Connect();
|
||||
// }
|
||||
// }
|
||||
//}, Debug.Log);
|
||||
App.MainDeviceAdapter.StartScan();
|
||||
|
||||
|
||||
//Debug.Log(Application.dataPath);
|
||||
App.MainDeviceAdapter.StartScan();
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
@@ -76,6 +65,8 @@ public class MainController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
@@ -87,9 +78,4 @@ public class MainController : MonoBehaviour
|
||||
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
|
||||
App.CurrentUser = result.data;
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
App.MainDeviceAdapter.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user