参考のため、私が作成した Unityの Project群を Google Drive でそのまま公開 します。 (4年ゼミの学生のみアクセス可)
各UnityのProject内には、私の Google Map API_KEY が含まれています。 決してそのままでは動作させず、 自分で取得したAPI_KEY に差し替えて動作させて下さい。 具体的には、「 Unityのhierarchyウィンドウの中の9個の Map_Tiles/Map_Tile_X_Y (X=-1,0,1, Y=-1,0,1) に attach された GoogleMapTile (Script) コンポーネント のAPI_KEY の値を自分のAPI_KEYに変更して下さい 」 ということです。
Player
)のInspectorに
API_KEYの入力欄が表示されるので、そこに値を入力する。
[2019.10.20記]GoogleMapTile.cs への変更 |
*** ch02/GoogleMapTile_org.cs Thu Oct 17 17:19:04 2019 --- ch02/GoogleMapTile.cs Mon Oct 21 10:58:04 2019 *************** *** 16,21 **** --- 16,22 ---- Hybrid } + public string api_key =""; // added by [email protected] 2019/10/17 private const string GOOGLE_MAPS_URL = "http://maps.googleapis.com/maps/api/staticmap"; public int zoomLevel = 1; *************** *** 95,101 **** print(string.Format("Tile {0}x{1} requested with {2}", TileOffset.x, TileOffset.y, queryString)); ! var req = new WWW(url + "?" + queryString); //var req = new WWW("https://maps.googleapis.com/maps/api/staticmap?center=50.917316,-114.080923&zoom=17&format=png&sensor=false&size=640x640&scale=2&maptype=roadmap&style=feature:landscape.man_made|visibility:on|invert_lightness:true"); yield return req; GetComponent<Renderer>().material.mainTexture = req.texture; --- 96,102 ---- print(string.Format("Tile {0}x{1} requested with {2}", TileOffset.x, TileOffset.y, queryString)); ! var req = new WWW(url + "?" + queryString + "&key="+api_key); // changed by [email protected] 2019/10/17 //var req = new WWW("https://maps.googleapis.com/maps/api/staticmap?center=50.917316,-114.080923&zoom=17&format=png&sensor=false&size=640x640&scale=2&maptype=roadmap&style=feature:landscape.man_made|visibility:on|invert_lightness:true"); yield return req; GetComponent<Renderer>().material.mainTexture = req.texture; |
誤: の精度の設定を1から10に変更して下さい。
正: の精度の設定を110から101に変更して下さい。
Timestamp
の値を更新していないためである。[2019/10/21記]GPSLocationService.cs への変更 |
*** ch04/GPSLocationService_org.cs Mon Oct 21 20:20:15 2019 --- ch04/GPSLocationService.cs Wed Oct 23 11:21:53 2019 *************** *** 102,107 **** --- 102,108 ---- print("GSPLocationService started"); // Access granted and location value could be retrieved print("Location initialized at: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp); + Timestamp = Input.location.lastData.timestamp; // added by nitta Oct/21/2019 CenterMap(); IsServiceStarted = true; } *************** *** 141,148 **** mapWorldCenter.x = GoogleMapUtils.LonToX(mapCenter.Longitude); mapWorldCenter.y = GoogleMapUtils.LatToY(mapCenter.Latitude); ! mapScale.x = GoogleMapUtils.CalculateScaleX(Latitude, MapTileSizePixels, MapTileScale, MapTileZoomLevel); ! mapScale.y = GoogleMapUtils.CalculateScaleY(Longitude, MapTileSizePixels, MapTileScale, MapTileZoomLevel); var lon1 = GoogleMapUtils.adjustLonByPixels(Longitude, -MapTileSizePixels/2, MapTileZoomLevel); var lat1 = GoogleMapUtils.adjustLatByPixels(Latitude, MapTileSizePixels/2, MapTileZoomLevel); --- 142,149 ---- mapWorldCenter.x = GoogleMapUtils.LonToX(mapCenter.Longitude); mapWorldCenter.y = GoogleMapUtils.LatToY(mapCenter.Latitude); ! mapScale.x = GoogleMapUtils.CalculateScaleX(Longitude, MapTileSizePixels, MapTileScale, MapTileZoomLevel); ! mapScale.y = GoogleMapUtils.CalculateScaleY(Latitude, MapTileSizePixels, MapTileScale, MapTileZoomLevel); var lon1 = GoogleMapUtils.adjustLonByPixels(Longitude, -MapTileSizePixels/2, MapTileZoomLevel); var lat1 = GoogleMapUtils.adjustLatByPixels(Latitude, MapTileSizePixels/2, MapTileZoomLevel); |
![]() |
[邦訳] UnityによるARゲーム開発 ―作りながら学ぶオーグメンテッドリアリティ入門 Micheal Lanham (著) 高橋 憲一 , あんどうやすし, 江川 崇, 安藤 幸央 (翻訳), 出版社: オライリージャパン (2017/9/2) ISBN-10: 4873118107 ISBN-13: 978-4873118109 本の情報: https://www.oreilly.co.jp/books/9784873118109 ソース・プログラム: github 展開したソース(学内のみアクセス可) |
![]() |
[原著] Augmented Reality Game Development Micheal Lanham Publisher: Packt Publishing; 1 edition (January 20, 2017) ISBN: 9781787122888 本の情報: https://www.packtpub.com/application-development/augmented-reality-game-development ソース・プログラム: github 展開したソース(学内のみアクセス可) ソース中の各章のpackageをimportした後のAssets内のファイル(学内のみアクセス可) |