96 lines
2.8 KiB
C#
96 lines
2.8 KiB
C#
using Assets.Scripts;
|
|
using Assets.Scripts.Devices.Ant;
|
|
using Assets.Scripts.UI.Prefab.Device;
|
|
using Mapbox.Examples;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class MainController : MonoBehaviour
|
|
{
|
|
[SerializeField]GameObject root;
|
|
private Text Version;
|
|
private void Awake()
|
|
{
|
|
Version = this.transform.Find("GameObject").Find("Version").GetComponent<Text>();
|
|
Version.text = "V"+App.AppVersion;
|
|
DeviceCache.Init(PFConstants.DeviceCacheFolder);
|
|
|
|
//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);
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
async void Start()
|
|
{
|
|
UIManager.Instance.Root = root;
|
|
UIManager.Instance.MainPanel = this.transform.Find("Panel").GetComponent<PFUIPanel>();
|
|
UIManager.Instance.ModalsPanel = this.transform.Find("ModalPanel").GetComponent<PFUIPanel>();
|
|
#if UNITY_EDITOR
|
|
if (App.CurrentUser == null) //App.CurrentUser == null
|
|
{
|
|
await Login();
|
|
}
|
|
#endif
|
|
//MainMenu.transform.Find("Home").GetComponent<Button>().onClick.AddListener(() =>
|
|
//{
|
|
// UIManager.ShowHomePanel();
|
|
//});
|
|
if (App.MainSceneParam.ContainsKey("Name") && !string.IsNullOrEmpty(App.MainSceneParam["Name"]))
|
|
{
|
|
UIManager.PushHome();
|
|
if (App.MainSceneParam["Name"] == "MapListPanel")
|
|
{
|
|
UIManager.ShowMapListPanel();
|
|
}
|
|
|
|
if (App.MainSceneParam["Name"] == "UserInfoPanel")
|
|
{
|
|
UIManager.ShowUserInfoPanel();
|
|
}
|
|
App.MainSceneParam["Name"] = string.Empty;
|
|
}
|
|
else
|
|
{
|
|
UIManager.ShowHomePanel();
|
|
//UIManager.ShowUserInfoPanel();
|
|
//UIManager.ShowEditUserPanel();
|
|
//UIManager.ShowBigMapPanel();
|
|
//UIManager.ShowEarthPanel();
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
private async Task Login()
|
|
{
|
|
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
|
|
App.CurrentUser = result.data;
|
|
}
|
|
|
|
private void OnApplicationQuit()
|
|
{
|
|
App.MainDeviceAdapter.Dispose();
|
|
}
|
|
}
|