HomeViewRenderBow.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.EventSystems;
  6. public class HomeViewRenderBow : MonoBehaviour
  7. {
  8. [SerializeField] GameObject prefabRenderBowCamera;
  9. [SerializeField] GameObject btnConnectBow;
  10. GameObject renderBowCamera;
  11. Transform sphere;
  12. void Start()
  13. {
  14. renderBowCamera = Instantiate(prefabRenderBowCamera);
  15. sphere = renderBowCamera.transform.Find("Sphere");
  16. btnConnectBow.GetComponent<Button>().onClick.AddListener(delegate() {
  17. BluetoothAim.ins.DoConnect();
  18. });
  19. }
  20. void Update()
  21. {
  22. sphere.Rotate(Vector3.up, Time.deltaTime * 60);
  23. UpdateBtnForConnect();
  24. }
  25. BluetoothStatusEnum bowStatus;
  26. void UpdateBtnForConnect() {
  27. if (BluetoothAim.ins && bowStatus != BluetoothAim.ins.status) {
  28. bowStatus = BluetoothAim.ins.status;
  29. (int textID, Color color) = BluetoothStatus.GetStatusInfo(BluetoothAim.ins.status);
  30. btnConnectBow.GetComponentInChildren<TextAutoLanguage>().SetText(textID);
  31. btnConnectBow.GetComponentInChildren<Text>().color = color;
  32. btnConnectBow.transform.Find("Check").gameObject.SetActive(bowStatus == BluetoothStatusEnum.ConnectSuccess);
  33. }
  34. }
  35. public void OnClick_ShowDeviceView() {
  36. AudioMgr.ins.PlayBtn();
  37. GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/DeviceView 1"));
  38. }
  39. }