DCDC24-EmissionVision/Assets/WorldPoliticalMapGlobeEdition/Demos/02 SpriteMarkers/AddMarkerScript.cs
Negin Soltani 37239732ac Initial Push
- Globe Asset
- Spatial Anchors
- Photon Implementation
- Scripts for Globe Control and Initial Country Colorizing
- Script for Reading csv file
2024-05-16 14:41:23 +02:00

37 lines
1.1 KiB
C#

using UnityEngine;
using System.Collections;
namespace WPM {
public class AddMarkerScript : MonoBehaviour {
GameObject destinationSprite;
void Start () {
float latitude = 40.71f;
float longitude = -74f;
WorldMapGlobe map = WorldMapGlobe.instance;
Vector3 sphereLocation = Conversion.GetSpherePointFromLatLon (latitude, longitude);
// Create sprite
destinationSprite = new GameObject ();
SpriteRenderer dest_sprite = destinationSprite.AddComponent<SpriteRenderer> ();
dest_sprite.sprite = Resources.Load<Sprite> ("NewYork");
// Add sprite billboard to the map with custom scale, billboard mode and little bit elevated from surface (to prevent clipping with city spots)
map.AddMarker (destinationSprite, sphereLocation, 0.02f, true, 0.1f);
// Add click handlers
destinationSprite.AddComponent<SpriteClickHandler> ();
// Locate it on the map
map.FlyToLocation (sphereLocation, 4f, 0.4f);
map.autoRotationSpeed = 0f;
}
void Update () {
destinationSprite.transform.Rotate (new Vector3 (0, 0, 5f * Time.deltaTime), Space.Self);
}
}
}