質問編集履歴
1
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
【Xcodeビルドエラー】Unity使用したSwiftとObject-C間のエラー
|
1
|
+
【Xcodeビルドエラー】Unity使用したSwiftとObject-C間のエラーNo visible @interface for 'xxx' declares the selector 'xxx'
|
test
CHANGED
@@ -26,9 +26,42 @@
|
|
26
26
|
{
|
27
27
|
@objc public static let shared = SwiftToUnity()
|
28
28
|
|
29
|
-
@objc static func showMap(frame:CGRect, placeJson: String)
|
29
|
+
@objc static func showMap(frame:CGRect, placeJson: String) {
|
30
|
+
|
31
|
+
guard let view = UnityGetGLView() else {
|
32
|
+
return
|
30
|
-
|
33
|
+
}
|
34
|
+
let mapView = MKMapView(frame: frame)
|
35
|
+
|
36
|
+
// Unityから送られてくるピン情報はJSONなので、パースする。
|
37
|
+
let jsonData = placeJson.data(using: .utf8)!
|
38
|
+
let decoder = JSONDecoder()
|
39
|
+
let placeList = try! decoder.decode(PlaceList.self, from: jsonData)
|
40
|
+
|
41
|
+
placeList.places.forEach { // ピンを配置する
|
42
|
+
let annotation = MKPointAnnotation()
|
43
|
+
annotation.coordinate = CLLocationCoordinate2DMake($0.latitude, $0.longitude)
|
44
|
+
annotation.title = $0.title
|
45
|
+
mapView.addAnnotation(annotation)
|
46
|
+
}
|
47
|
+
|
48
|
+
view.addSubview(mapView)
|
49
|
+
|
50
|
+
}
|
51
|
+
}
|
52
|
+
/// ピン情報のリスト (UnityのJsonUtilityが配列がルートのJSONに対応していないため
|
53
|
+
struct PlaceList: Codable {
|
31
|
-
|
54
|
+
let places: [Place]
|
55
|
+
}
|
56
|
+
|
57
|
+
/// ピン情報のモデル
|
58
|
+
struct Place: Codable {
|
59
|
+
let id: Int
|
60
|
+
let title: String
|
61
|
+
let latitude: Double
|
62
|
+
let longitude: Double
|
63
|
+
}
|
64
|
+
|
32
65
|
```
|
33
66
|
---
|
34
67
|
|