骑行内存优化&设备连接点击优化
This commit is contained in:
1 parent
004410048f
commit
8b3dd7a40a
11 files changed
+7495
-2133
No files matched your search
@@ -72,8 +72,11 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
this.Close();
|
||||
//DestroyImmediate(this.gameObject);
|
||||
}));
|
||||
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
deviceItem = Resources.Load("UI/Prefab/Device/Mobile/DeviceItem");
|
||||
#else
|
||||
deviceItem = Resources.Load("UI/Prefab/Device/DeviceItem");
|
||||
#endif
|
||||
|
||||
connectBtn = container.Find("ConnectBtn").GetComponent<PfUIButton>();
|
||||
connectBtnText = connectBtn.transform.Find("Text").GetComponent<Text>();
|
||||
|
||||
@@ -29,7 +29,8 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
|
||||
protected override void Start()
|
||||
{
|
||||
//this.currentSelectionState = SelectionState.Selected
|
||||
|
||||
if (DeviceInfo == null)
|
||||
return;
|
||||
mText.text = DeviceInfo.Name;// + "-" + DeviceInfo.DeviceNumber;
|
||||
if(DeviceInfo.Network == NetworkType.ANT)
|
||||
{
|
||||
|
||||
@@ -58,6 +58,9 @@ public class DeviceView : MonoBehaviour
|
||||
/// </summary>
|
||||
private Sprite sprite3;
|
||||
|
||||
private Button unconnectionButton;
|
||||
private Button connectionButton;
|
||||
|
||||
private float timer = 1.0f;
|
||||
private void Awake()
|
||||
{
|
||||
@@ -67,9 +70,10 @@ public class DeviceView : MonoBehaviour
|
||||
mSearchButton = unconnectionPanel.transform.Find("SearchButton").gameObject;
|
||||
mPairButton = unconnectionPanel.transform.Find("PairButton").gameObject;
|
||||
searchState = unconnectionPanel.transform.Find("SearchState").GetComponent<Text>();
|
||||
unconnectionButton = unconnectionPanel.GetComponent<Button>();
|
||||
mPairButton.SetActive(false);
|
||||
connectionPanel = this.transform.Find("ConnectionPanel").gameObject;
|
||||
|
||||
connectionButton = connectionPanel.GetComponent<Button>();
|
||||
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.2f, 0));
|
||||
@@ -122,41 +126,68 @@ public class DeviceView : MonoBehaviour
|
||||
|
||||
connectionPanel.SetActive(false);
|
||||
|
||||
UIManager.AddEvent(mPairButton, EventTriggerType.PointerClick, new UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
UIManager.AddEvent(unconnectionButton.gameObject, EventTriggerType.PointerClick, new UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
{
|
||||
if (deviceModal == null)
|
||||
if (!mPairButton.activeSelf)
|
||||
{
|
||||
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
var obj = Resources.Load("UI/Prefab/Device/Mobile/ConnectDeviceModal");
|
||||
#else
|
||||
var obj = Resources.Load("UI/Prefab/Device/ConnectDeviceModal");
|
||||
#endif
|
||||
GameObject gameObject = (GameObject)Instantiate(obj);
|
||||
deviceModal = gameObject.GetComponent<ConnectDeviceModal>();
|
||||
return;
|
||||
}
|
||||
deviceModal.SensorType = this.SensorType;
|
||||
UIManager.Show(deviceModal, null, true);
|
||||
connectButtonClick();
|
||||
}));
|
||||
|
||||
|
||||
UIManager.AddEvent(mPairButton, EventTriggerType.PointerClick, new UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
{
|
||||
connectButtonClick();
|
||||
}));
|
||||
|
||||
UIManager.AddEvent(connectionButton.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e => {
|
||||
if (!mPairButton.activeSelf)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mDisconnectButtonClick();
|
||||
}));
|
||||
|
||||
|
||||
UIManager.AddEvent(mDisconnectButton, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e => {
|
||||
//var device = GetDevice();
|
||||
//if(device != null && device.State == DeviceState.Connected)
|
||||
//{
|
||||
// device.Disconnect();
|
||||
//}
|
||||
mDisconnectButtonClick();
|
||||
}));
|
||||
|
||||
}
|
||||
void connectButtonClick()
|
||||
{
|
||||
if (deviceModal == null)
|
||||
{
|
||||
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
var obj = Resources.Load("UI/Prefab/Device/Mobile/ConnectDeviceModal");
|
||||
#else
|
||||
var obj = Resources.Load("UI/Prefab/Device/ConnectDeviceModal");
|
||||
var obj = Resources.Load("UI/Prefab/Device/ConnectDeviceModal");
|
||||
#endif
|
||||
GameObject gameObject = (GameObject)Instantiate(obj);
|
||||
deviceModal = gameObject.GetComponent<ConnectDeviceModal>();
|
||||
deviceModal.SensorType = this.SensorType;
|
||||
UIManager.Show(deviceModal, null, true);
|
||||
}));
|
||||
}
|
||||
deviceModal.SensorType = this.SensorType;
|
||||
UIManager.Show(deviceModal, null, true);
|
||||
}
|
||||
void mDisconnectButtonClick()
|
||||
{
|
||||
//var device = GetDevice();
|
||||
//if(device != null && device.State == DeviceState.Connected)
|
||||
//{
|
||||
// device.Disconnect();
|
||||
//}
|
||||
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
var obj = Resources.Load("UI/Prefab/Device/Mobile/ConnectDeviceModal");
|
||||
#else
|
||||
var obj = Resources.Load("UI/Prefab/Device/ConnectDeviceModal");
|
||||
#endif
|
||||
GameObject gameObject = (GameObject)Instantiate(obj);
|
||||
deviceModal = gameObject.GetComponent<ConnectDeviceModal>();
|
||||
deviceModal.SensorType = this.SensorType;
|
||||
UIManager.Show(deviceModal, null, true);
|
||||
}
|
||||
|
||||
void InitLogo()
|
||||
|
||||
Reference in new issue
Block a user