private void Start() { setBeaconPropertiesAtStart(); // please keep here! _bluetoothButton.onClick.AddListener(delegate() { BluetoothState.EnableBluetooth(); }); _bluetoothText = _bluetoothButton.GetComponentInChildren <Text>(); BluetoothState.BluetoothStateChangedEvent += delegate(BluetoothLowEnergyState state) { switch (state) { case BluetoothLowEnergyState.TURNING_OFF: case BluetoothLowEnergyState.TURNING_ON: break; case BluetoothLowEnergyState.UNKNOWN: case BluetoothLowEnergyState.RESETTING: SwitchToStatus(); _statusText.text = "Checking Device…"; break; case BluetoothLowEnergyState.UNAUTHORIZED: SwitchToStatus(); _statusText.text = "You don't have the permission to use beacons."; break; case BluetoothLowEnergyState.UNSUPPORTED: SwitchToStatus(); _statusText.text = "Your device doesn't support beacons."; break; case BluetoothLowEnergyState.POWERED_OFF: SwitchToMenu(); _bluetoothButton.interactable = true; _bluetoothText.text = "Enable Bluetooth"; break; case BluetoothLowEnergyState.POWERED_ON: SwitchToMenu(); _bluetoothButton.interactable = false; _bluetoothText.text = "Bluetooth already enabled"; break; case BluetoothLowEnergyState.IBEACON_ONLY: SwitchToMenu(); _bluetoothButton.interactable = false; _bluetoothText.text = "iBeacon only"; break; default: SwitchToStatus(); _statusText.text = "Unknown Error"; break; } }; f_ScrollViewContentRectWidth = ((RectTransform)go_FoundBeacon.transform).rect.width; f_ScrollViewContentRectHeight = ((RectTransform)go_FoundBeacon.transform).rect.height; BluetoothState.Init(); }
private static void InternInit(bool shouldLog) { if (initialized) { Scan(); return; } if (m_instance == null) { m_instance = FindObjectOfType <iBeaconReceiver>(); if (m_instance == null) { BluetoothState.Init(); m_instance = GameObject.Find(BluetoothState.NAME).AddComponent <iBeaconReceiver>(); } } Stop(); var state = BluetoothState.GetBluetoothLEStatus(); if (state == BluetoothLowEnergyState.IBEACON_ONLY) { if (regions.Any(region => region.beacon.type == BeaconType.iBeacon)) { Debug.LogWarning(MessageiBeaconOnly); } else { throw new iBeaconException(MessageiBeaconOnly); } } else if (state != BluetoothLowEnergyState.POWERED_ON) { BluetoothState.EnableBluetooth(); if (BluetoothState.GetBluetoothLEStatus() != BluetoothLowEnergyState.POWERED_ON) { throw new iBeaconException("Bluetooth is off and could not be enabled."); } } #if !UNITY_EDITOR #if UNITY_IOS if (!InitReceiver(iBeaconRegion.regionsToString(m_instance._regions), shouldLog)) { throw new iBeaconException("Receiver initialization failed."); } #elif UNITY_ANDROID GetPlugin().Call( "Init", iBeaconRegion.regionsToString(m_instance._regions), Mathf.FloorToInt(m_instance._detectionTimespan * 1000), Mathf.FloorToInt(m_instance._scanPeriod * 1000), Mathf.FloorToInt(m_instance._betweenScanPeriod * 1000), shouldLog); #endif #endif initialized = true; Scan(); }
private void Start() { _bluetoothButton.onClick.AddListener(delegate() { BluetoothState.EnableBluetooth(); }); _bluetoothText = _bluetoothButton.GetComponentInChildren <Text> (); BluetoothState.BluetoothStateChangedEvent += delegate(BluetoothLowEnergyState state) { switch (state) { case BluetoothLowEnergyState.TURNING_OFF: case BluetoothLowEnergyState.TURNING_ON: break; case BluetoothLowEnergyState.UNKNOWN: case BluetoothLowEnergyState.RESETTING: break; case BluetoothLowEnergyState.UNAUTHORIZED: break; case BluetoothLowEnergyState.UNSUPPORTED: break; case BluetoothLowEnergyState.POWERED_OFF: _bluetoothButton.interactable = true; break; case BluetoothLowEnergyState.POWERED_ON: _bluetoothButton.interactable = false; break; default: break; } }; BluetoothState.Init(); _camera = GameObject.FindGameObjectWithTag("MainCamera");// posCamera = new Vector3(0, 0, -9); MapImage = GameObject.Find("Map").transform.Find("Map_Image").gameObject; btnGetYokai.transform.GetChild(0).GetComponent <Text>().text = ApplicationData.GetLocaleText(LocaleType.ButtonToSeal); btnGetYokai.transform.GetChild(0).GetComponent <Text>().fontSize = ApplicationData.SetFontSize(LocaleType.ButtonToSeal); btnSuccess.transform.GetChild(0).GetComponent <Text>().text = ApplicationData.GetLocaleText(LocaleType.ButtonGetSuccessful); btnSuccess.transform.GetChild(0).GetComponent <Text>().fontSize = ApplicationData.SetFontSize(LocaleType.ButtonGetSuccessful); if (ApplicationData.SelectedLanguage == LanguageType.Thai) { btnGetYokai.transform.GetChild(0).GetComponent <Text> ().font = ApplicationData.GetFont(4); btnSuccess.transform.GetChild(0).GetComponent <Text>().font = ApplicationData.GetFont(4); } else { btnGetYokai.transform.GetChild(0).GetComponent <Text> ().font = ApplicationData.GetFont(2); btnSuccess.transform.GetChild(0).GetComponent <Text>().font = ApplicationData.GetFont(2); } }
private static void InternInit(bool shouldLog) { if (initialized) { Transmit(); return; } if (m_instance == null) { m_instance = FindObjectOfType <iBeaconServer>(); if (m_instance == null) { BluetoothState.Init(); m_instance = GameObject.Find(BluetoothState.NAME).AddComponent <iBeaconServer>(); } } StopTransmit(); if (BluetoothState.GetBluetoothLEStatus() != BluetoothLowEnergyState.POWERED_ON) { BluetoothState.EnableBluetooth(); if (BluetoothState.GetBluetoothLEStatus() != BluetoothLowEnergyState.POWERED_ON) { throw new iBeaconException("Bluetooth is off and could not be enabled."); } } if (!checkTransmissionSupported(shouldLog)) { throw new iBeaconException("This device does not support transmitting as a beacon."); } #if !UNITY_EDITOR var sb = new StringBuilder(JsonUtility.ToJson(m_instance._region)); sb.Insert(sb.Length - 1, ",\"_txPower\":"); sb.Insert(sb.Length - 1, m_instance._txPower); #if UNITY_IOS if (!InitBeaconServer(sb.ToString(), shouldLog)) { throw new iBeaconException("Server initialization failed."); } #elif UNITY_ANDROID sb.Insert(sb.Length - 1, ",\"_powerLevel\":"); sb.Insert(sb.Length - 1, (int)m_instance._powerLevel); sb.Insert(sb.Length - 1, ",\"_mode\":"); sb.Insert(sb.Length - 1, (int)m_instance._mode); if (!GetPlugin().Call <bool>("Init", sb.ToString(), shouldLog)) { throw new iBeaconException("Server initialization failed."); } #endif #endif initialized = true; Transmit(); }
void Start() { // Enable Bluetooth BluetoothState.Init(); BluetoothState.EnableBluetooth(); //Init Pop Up PopUpDetected.active = false; PopUpLoading.active = false; // Auto Region s_Region = "Indonesia"; // Button Listener ScanBtn.onClick.AddListener(startScan); }
private void Start() { BluetoothState.BluetoothStateChangedEvent += delegate(BluetoothLowEnergyState state) { switch (state) { case BluetoothLowEnergyState.TURNING_OFF: case BluetoothLowEnergyState.TURNING_ON: break; case BluetoothLowEnergyState.UNKNOWN: case BluetoothLowEnergyState.RESETTING: // SwitchToStatus(); // _statusText.text = "Checking Device…"; break; case BluetoothLowEnergyState.UNAUTHORIZED: // SwitchToStatus(); // _statusText.text = "You don't have the permission to use beacons."; break; case BluetoothLowEnergyState.UNSUPPORTED: // SwitchToStatus(); // _statusText.text = "Your device doesn't support beacons."; break; case BluetoothLowEnergyState.POWERED_OFF: // SwitchToMenu(); // _bluetoothButton.interactable = true; // _bluetoothText.text = "Enable Bluetooth"; break; case BluetoothLowEnergyState.POWERED_ON: // SwitchToMenu(); // _bluetoothButton.interactable = false; // _bluetoothText.text = "Bluetooth already enabled"; break; default: // SwitchToStatus(); // _statusText.text = "Unknown Error"; break; } }; BluetoothState.Init(); }
private static void InternInit(bool shouldLog) { if (initialized) { Scan(); return; } if (m_instance == null) { m_instance = FindObjectOfType <iBeaconReceiver>(); if (m_instance == null) { BluetoothState.Init(); m_instance = GameObject.Find(BluetoothState.NAME).AddComponent <iBeaconReceiver>(); } } Stop(); if (BluetoothState.GetBluetoothLEStatus() != BluetoothLowEnergyState.POWERED_ON) { BluetoothState.EnableBluetooth(); if (BluetoothState.GetBluetoothLEStatus() != BluetoothLowEnergyState.POWERED_ON) { throw new iBeaconException("Bluetooth is off and could not be enabled."); } } #if !UNITY_EDITOR #if UNITY_IOS if (!InitReceiver(iBeaconRegion.regionsToString(m_instance._regions), shouldLog)) { throw new iBeaconException("Receiver initialization failed."); } #elif UNITY_ANDROID GetPlugin().Call( "Init", iBeaconRegion.regionsToString(m_instance._regions), Mathf.FloorToInt(m_instance._androidDetectionTimespan * 1000), shouldLog); #endif #endif initialized = true; Scan(); }
private void Start() { //-------------------------------------------------- _txtBC1rssi = GameObject.Find("Canvas/B1_rssi").GetComponent <Text>(); _txtBC2rssi = GameObject.Find("Canvas/B2_rssi").GetComponent <Text>(); _txtBC3rssi = GameObject.Find("Canvas/B3_rssi").GetComponent <Text>(); _txtBC4rssi = GameObject.Find("Canvas/B4_rssi").GetComponent <Text>(); _txtBC1meter = GameObject.Find("Canvas/B1_meter").GetComponent <Text>(); _txtBC2meter = GameObject.Find("Canvas/B2_meter").GetComponent <Text>(); _txtBC3meter = GameObject.Find("Canvas/B3_meter").GetComponent <Text>(); _txtBC4meter = GameObject.Find("Canvas/B4_meter").GetComponent <Text>(); _txtBC1ave = GameObject.Find("Canvas/B1_ave").GetComponent <Text>(); _txtBC2ave = GameObject.Find("Canvas/B2_ave").GetComponent <Text>(); _txtBC3ave = GameObject.Find("Canvas/B3_ave").GetComponent <Text>(); _txtBC4ave = GameObject.Find("Canvas/B4_ave").GetComponent <Text>(); /*_POSx = GameObject.Find("Canvas/POS_X").GetComponent<Text>(); * _POSy = GameObject.Find("Canvas/POS_Y").GetComponent<Text>(); * _POSz = GameObject.Find("Canvas/POS_Z").GetComponent<Text>();*/ //-------------------- /*_DEBUG1 = GameObject.Find("Canvas/DEBUG1").GetComponent<Text>(); * _DEBUG2 = GameObject.Find("Canvas/DEBUG2").GetComponent<Text>(); * _DEBUG3 = GameObject.Find("Canvas/DEBUG3").GetComponent<Text>();*/ //-------------------- _ssbutton = GameObject.Find("Canvas/Button").GetComponent <Button>(); /*_B1name = GameObject.Find("Canvas/B1_name").GetComponent<InputField>(); * _B2name = GameObject.Find("Canvas/B2_name").GetComponent<InputField>(); * _B3name = GameObject.Find("Canvas/B3_name").GetComponent<InputField>(); * _B4name = GameObject.Find("Canvas/B4_name").GetComponent<InputField>();*/ _B1minor = GameObject.Find("Canvas/B1_minor").GetComponent <InputField>(); _B2minor = GameObject.Find("Canvas/B2_minor").GetComponent <InputField>(); _B3minor = GameObject.Find("Canvas/B3_minor").GetComponent <InputField>(); _B4minor = GameObject.Find("Canvas/B4_minor").GetComponent <InputField>(); //_POS12 = GameObject.Find("Canvas/POS_B1B2").GetComponent<InputField>(); //_POS23 = GameObject.Find("Canvas/POS_B2B3").GetComponent<InputField>(); //_POS34 = GameObject.Find("Canvas/POS_B3B4").GetComponent<InputField>(); //_POS14 = GameObject.Find("Canvas/POS_B1B4").GetComponent<InputField>(); /*_IFB1str = GameObject.Find("Canvas/IF_B1str").GetComponent<InputField>(); * _IFB2str = GameObject.Find("Canvas/IF_B2str").GetComponent<InputField>(); * _IFB3str = GameObject.Find("Canvas/IF_B3str").GetComponent<InputField>(); * _IFB4str = GameObject.Find("Canvas/IF_B4str").GetComponent<InputField>();*/ _IFEV = GameObject.Find("Canvas/IF_EV").GetComponent <InputField>(); //_IFHT = GameObject.Find("Canvas/IF_HT").GetComponent<InputField>(); //-------------------------------------------------- setBeaconPropertiesAtStart(); // 初始設定 // 藍芽狀態偵測(目前未使用) BluetoothState.BluetoothStateChangedEvent += delegate(BluetoothLowEnergyState state) { switch (state) { case BluetoothLowEnergyState.TURNING_OFF: case BluetoothLowEnergyState.TURNING_ON: break; case BluetoothLowEnergyState.UNKNOWN: case BluetoothLowEnergyState.RESETTING: //_statusText.text = "Checking Device…"; break; case BluetoothLowEnergyState.UNAUTHORIZED: //_statusText.text = "You don't have the permission to use beacons."; break; case BluetoothLowEnergyState.UNSUPPORTED: //_statusText.text = "Your device doesn't support beacons."; break; case BluetoothLowEnergyState.POWERED_OFF: //_bluetoothButton.interactable = true; //_bluetoothText.text = "Enable Bluetooth"; break; case BluetoothLowEnergyState.POWERED_ON: //_bluetoothButton.interactable = false; //_bluetoothText.text = "Bluetooth already enabled"; break; default: //_statusText.text = "Unknown Error"; break; } }; BluetoothState.Init(); }