|
- using UnityEngine;
- using System.Collections.Generic;
- public class CoreLocationGUIManager : MonoBehaviour
- {
- public GUIText text1;
- public GUIText text2;
-
- public GUIText text3;
- public GUIText text4;
- int modulous = 0;
-
-
- void Start()
- {
- // kill the dang keyboard frame
- iPhoneKeyboard.autorotateToPortrait = false;
- iPhoneKeyboard.autorotateToPortraitUpsideDown = false;
- iPhoneKeyboard.autorotateToLandscapeRight = false;
- iPhoneKeyboard.autorotateToLandscapeLeft = false;
-
- // listen for location changes
- CoreLocationManager.locationServicesDidUpdate += locationServicesDidUpdate;
- }
-
-
- public void locationServicesDidUpdate( CoreLocationData locationData )
- {
- Debug.Log( "locationServicesDidUpdate event: " + locationData );
-
- text1.text = locationData.latitude.ToString();
- text2.text = locationData.longitude.ToString();
- }
-
-
- void Update()
- {
- // only grab the compass data every 10 frames
- if( modulous++ % 10 == 0 )
- {
- text3.text = CoreLocationBinding.getMagneticHeading().ToString();
- text4.text = CoreLocationBinding.getTrueHeading().ToString();
- }
- }
-
-
- void OnGUI()
- {
- float yPos = 10.0f;
- float xPos = 20.0f;
- float width = 160.0f;
-
- if( GUI.Button( new Rect( xPos, yPos, width, 40 ), "Is Compass Avaialble?" ) )
- {
- bool compassAvailable = CoreLocationBinding.isCompassAvailable();
- Debug.Log( "CoreMotion isCompassAvailable: " + compassAvailable );
- }
-
-
- if( GUI.Button( new Rect( xPos, yPos += 50, width, 40 ), "Set Distance Filter to 10" ) )
- {
- CoreLocationBinding.setDistanceFilter( 10 );
- }
-
-
- if( GUI.Button( new Rect( xPos, yPos += 50, width, 40 ), "Set Heading Filter to 3" ) )
- {
- CoreLocationBinding.setHeadingFilter( 3 );
- }
-
-
- if( GUI.Button( new Rect( xPos, yPos += 50, width, 40 ), "Start Updating Location" ) )
- {
- CoreLocationBinding.startUpdatingLocation();
- }
-
-
- if( GUI.Button( new Rect( xPos, yPos += 50, width, 40 ), "Stop Updating Location" ) )
- {
- CoreLocationBinding.stopUpdatingLocation();
- }
-
-
- // Second column
- xPos += xPos + width;
- yPos = 10.0f;
-
- if( GUI.Button( new Rect( xPos, yPos, width, 40 ), "Start Updating Heading" ) )
- {
- CoreLocationBinding.startUpdatingHeading();
- }
-
- if( GUI.Button( new Rect( xPos, yPos += 50, width, 40 ), "Stop Updating Heading" ) )
- {
- CoreLocationBinding.stopUpdatingHeading();
- }
-
- }
- }
复制代码 start中是对 横竖屏的控制下面就不知道了,谁测试下
没做过ios 所以不大懂
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|