Example #1
0
        protected override IEnumerable <MonoBehaviour> Create(Tile tile, JSONObject geo)
        {
            var kind = geo["properties"]["kind"].str.ConvertToPoiType();

            if (!FactorySettings.HasSettingsFor(kind) && !JustDrawEverythingFam)
            {
                yield break;
            }

            var typeSettings = FactorySettings.GetSettingsFor <PoiSettings>(kind);

            var go  = Instantiate(_labelPrefab);
            var poi = go.AddComponent <Poi>();

            poi.transform.SetParent(_container.transform, true);
            poi.GetComponentInChildren <Image>().sprite = typeSettings.Sprite;
            //if (geo["properties"].HasField("name"))
            //    go.GetComponentInChildren<TextMesh>().text = geo["properties"]["name"].str;

            var c            = geo["geometry"]["coordinates"];
            var dotMerc      = GM.LatLonToMeters(c[1].f, c[0].f);
            var localMercPos = dotMerc - tile.Rect.Center;

            go.transform.position = new Vector3((float)localMercPos.x, (float)localMercPos.y);
            var target = new GameObject("poiTarget");

            target.transform.position = localMercPos.ToVector3();
            target.transform.SetParent(tile.transform, false);
            poi.Stick(target.transform);

            SetProperties(geo, poi, typeSettings);

            yield return(poi);
        }
Example #2
0
        protected override IEnumerable <MonoBehaviour> Create(Tile tile, JSONObject geo)
        {
            var kind = geo["properties"]["kind"].str.ConvertToPoiType();

            if (!FactorySettings.HasSettingsFor(kind))
            {
                yield break;
            }

            var typeSettings = FactorySettings.GetSettingsFor <PoiSettings>(kind);

            var go  = new GameObject("Poi"); //Instantiate(_labelPrefab);
            var poi = go.AddComponent <Poi>();

            go.name = "poi-" + tile.name;
            //RJ added spriteRenderer
            var sprite = go.AddComponent <SpriteRenderer>();

            sprite.sprite = typeSettings.Sprite;
            //RJ DELETE? Sprite as 3d objects works better and Image doesn't work either?
            //poi.GetComponentInChildren<Image>().sprite = typeSettings.Sprite;


            //if (geo["properties"].HasField("name"))
            //    go.GetComponentInChildren<TextMesh>().text = geo["properties"]["name"].str;
            var c            = geo["geometry"]["coordinates"];
            var dotMerc      = GM.LatLonToMeters(c[1].f, c[0].f);
            var localMercPos = dotMerc - tile.Rect.Center;

            go.transform.position = new Vector3((float)localMercPos.x, (float)localMercPos.y, 30F);
            var target       = new GameObject("poiTarget");
            var targetScript = target.AddComponent <targetForPoi>();

            target.transform.position = localMercPos.ToVector3();
            target.transform.SetParent(tile.transform, false);
            poi.Stick(target.transform);
            poi.transform.localScale = new Vector3(.2f, .2f, .2f);
            poi.transform.SetParent(target.transform, true);

            SetProperties(geo, poi, typeSettings);
            targetScript.Name       = (poi.Name != null) ? poi.Name : poi.name;
            targetScript.Kind       = poi.Kind;
            targetScript.Properties = geo["properties"].ToString();
            yield return(poi);
        }