Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,974 changes: 2,928 additions & 46 deletions sdkproject/Assets/MapboxAR/Examples/Scenes/WorldScaleAR-ManualAlignment.unity

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions sdkproject/Assets/MapboxAR/Scripts/Camera/ManualTouchCamera.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
namespace Mapbox.Examples
{
// Just add this script to your camera. It doesn't need any configuration.

using UnityEngine;
using Mapbox.Unity.Location;

public class ManualTouchCamera : MonoBehaviour
{
[SerializeField]
Camera _camera;

[SerializeField]
Transform _mapRoot;

[SerializeField]
Transform _mapHolder;

float speed = 1f;

Vector2?[] _oldTouchPositions = { null, null };

Vector2 _oldTouchVector;
Vector3 _delta;
float _oldTouchDistance;
Vector3 _origin;

bool _wasTouching;

bool _shouldDrag;

void Update()
{

if (Input.touchCount == 0)
{
_oldTouchPositions[0] = null;
_oldTouchPositions[1] = null;
_shouldDrag = false;

}
else if (Input.touchCount == 1)
{
if (_oldTouchPositions[0] == null || _oldTouchPositions[1] != null)
{
_oldTouchPositions[0] = Input.GetTouch(0).position;
_oldTouchPositions[1] = null;
}

if (Input.GetTouch(0).phase == TouchPhase.Began)
{
_origin = Input.GetTouch(0).position;
}

if (Input.GetTouch(0).phase == TouchPhase.Moved)
{
var touchDelta = Input.GetTouch(0).deltaPosition;
var offset = new Vector3(touchDelta.x, 0f, touchDelta.y);
offset = _camera.transform.rotation * offset;
var newPos = new Vector3(offset.x, 0, offset.y);
_mapRoot.position = newPos + _mapRoot.position;
}
}
else
{
if (_oldTouchPositions[1] == null)
{
_oldTouchPositions[0] = Input.GetTouch(0).position;
_oldTouchPositions[1] = Input.GetTouch(1).position;
_oldTouchVector = (Vector2)(_oldTouchPositions[0] - _oldTouchPositions[1]);
_oldTouchDistance = _oldTouchVector.magnitude;
}
else
{
//Vector2 screen = new Vector2(_camera.pixelWidth, _camera.pixelHeight);
Vector2[] newTouchPositions = { Input.GetTouch(0).position, Input.GetTouch(1).position };
Vector2 newTouchVector = newTouchPositions[0] - newTouchPositions[1];
float newTouchDistance = newTouchVector.magnitude;
_mapHolder.rotation *= Quaternion.Euler(new Vector3(0, Mathf.Asin(Mathf.Clamp((_oldTouchVector.y * newTouchVector.x - _oldTouchVector.x * newTouchVector.y) / _oldTouchDistance / newTouchDistance, -1f, 1f)) / 0.0174532924f, 0));
_oldTouchPositions[0] = newTouchPositions[0];
_oldTouchPositions[1] = newTouchPositions[1];
_oldTouchVector = newTouchVector;
_oldTouchDistance = newTouchDistance;
}
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions sdkproject/Assets/MapboxAR/Scripts/FollowTargetTransform.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add namespace

using System.Collections.Generic;
using UnityEngine;

public class FollowTargetTransform : MonoBehaviour
{
[SerializeField]
Transform _targetTransform;

void Update()
{
transform.position = new Vector3(_targetTransform.position.x, transform.position.y, _targetTransform.position.z);
}
}
13 changes: 13 additions & 0 deletions sdkproject/Assets/MapboxAR/Scripts/FollowTargetTransform.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions sdkproject/Assets/MapboxAR/Scripts/RelocateMapByGPS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add namespace

using System.Collections.Generic;
using UnityEngine;
using Mapbox.Unity.Location;
using Mapbox.Unity.Map;
using UnityEngine.UI;

public class RelocateMapByGPS : MonoBehaviour
{

[SerializeField]
AbstractMap _map;

[SerializeField]
Button _button;

private void Start()
{
_button.onClick.AddListener(UpdateMapLocation);
}

public void UpdateMapLocation()
{
var location = LocationProviderFactory.Instance.DefaultLocationProvider.CurrentLocation;
_map.SetCenterLatitudeLongitude(location.LatitudeLongitude);
_map.GetComponent<Transform>().position = Camera.main.transform.position;
}
}
13 changes: 13 additions & 0 deletions sdkproject/Assets/MapboxAR/Scripts/RelocateMapByGPS.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions sdkproject/Assets/MapboxAR/Scripts/RotateOnYTargetTransform.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add namespace

using System.Collections.Generic;
using UnityEngine;

public class RotateOnYTargetTransform : MonoBehaviour
{
[SerializeField]
Transform _targetTransform;

void Update()
{
transform.eulerAngles = new Vector3(transform.eulerAngles.x, _targetTransform.eulerAngles.y, transform.eulerAngles.z);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions sdkproject/Assets/MapboxAR/Scripts/UpdateMapPosByARPlaneY.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add namespace.

using System.Collections.Generic;
using UnityEngine;
using UnityARInterface;

public class UpdateMapPosByARPlaneY : MonoBehaviour
{
[SerializeField]
Transform _mapRoot;


void Start()
{
ARInterface.planeAdded += UpdateMapPosOnY;
ARInterface.planeUpdated += UpdateMapPosOnY;
}

void UpdateMapPosOnY(BoundedPlane plane)
{
var pos = _mapRoot.position;
_mapRoot.position = new Vector3(pos.x, plane.center.y, pos.z);
}
}
13 changes: 13 additions & 0 deletions sdkproject/Assets/MapboxAR/Scripts/UpdateMapPosByARPlaneY.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions sdkproject/Assets/Resources.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions sdkproject/ProjectSettings/EditorBuildSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,48 @@ EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Main.unity
guid: 643bfa26e0eed440db629d1f4fc9f6ed
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Examples/0_PrefabScenes/CitySimulator.unity
guid: d24dbd32aba234c98826e2c59ebfdf84
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Examples/0_PrefabScenes/LocationBasedGame.unity
guid: 49f1ae7ff8c69466a9fd31117cca0599
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Examples/1_DataExplorer/DataExplorer.unity
guid: 028ca2c46390a4409bcf0fae61aef3b3
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Examples/2_ZoomableMap/ZoomableMap.unity
guid: 2c7147d54825142878b256c67aae5704
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Examples/3_Globe/Globe.unity
guid: 614e3e19125ae46c7af990b7e3debd36
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Examples/4_VoxelMap/VoxelMap.unity
guid: daabe3028a2c14661b829fff509af827
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Examples/5_Playground/Scenes/Directions.unity
guid: b650aa71f57a846dc83ef01c3c1755ad
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Examples/5_Playground/Scenes/ForwardGeocoder.unity
guid: 9683d5465276540cd9a4c9e89d931293
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Examples/5_Playground/Scenes/RasterTile.unity
guid: 893d0b4deb5544335b798dafd12ff9a7
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Examples/5_Playground/Scenes/ReverseGeocoder.unity
guid: 9a904a5fcec05469db76712a52999b39
- enabled: 1
- enabled: 0
path: Assets/Mapbox/Examples/5_Playground/Scenes/VectorTile.unity
guid: 416b524fd28da493a9b8e35443dbd25b
- enabled: 1
- enabled: 0
path: Assets/MapboxAR/Examples/Scenes/TabletopAR.unity
guid: a455922b0e2954431922c9fb6c5377e4
- enabled: 1
path: Assets/MapboxAR/Examples/Scenes/WorldScaleAR-ManualAlignment.unity
guid: d9ff170f22f0545c3970a889a592f312
- enabled: 1
- enabled: 0
path: Assets/MapboxAR/Examples/Scenes/WorldScaleAR.unity
guid: c60dfd6bb74264e44b3dbf93e9d129c4
5 changes: 2 additions & 3 deletions sdkproject/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PlayerSettings:
useOnDemandResources: 0
accelerometerFrequency: 60
companyName: Mapbox
productName: MBX SDK
productName: manual
defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
Expand Down Expand Up @@ -161,7 +161,7 @@ PlayerSettings:
Android: com.mapbox.unitysdk
Standalone: unity.Mapbox.MBX SDK
Tizen: com.mapbox.unitysdk
iOS: com.mapbox.MBX-SDK
iOS: com.mapbox.manual
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert back to MBX SDK

tvOS: com.mapbox.unitysdk
buildNumber:
iOS: 1
Expand Down Expand Up @@ -210,7 +210,6 @@ PlayerSettings:
tvOSSmallIconLayers: []
tvOSSmallIconLayers2x: []
tvOSLargeIconLayers: []
tvOSLargeIconLayers2x: []
tvOSTopShelfImageLayers: []
tvOSTopShelfImageLayers2x: []
tvOSTopShelfImageWideLayers: []
Expand Down