public override void Run(VectorEntity ve, UnityTile tile)
        {
            int selpos = ve.Feature.Points[0].Count / 2;
            var met    = ve.Feature.Points[0][selpos];

            IFeaturePropertySettable settable = null;
            GameObject go;

            if (_objects.ContainsKey(ve.GameObject))
            {
                go       = _objects[ve.GameObject];
                settable = go.GetComponent <IFeaturePropertySettable>();
                if (settable != null)
                {
                    go = (settable as MonoBehaviour).gameObject;
                    settable.Set(ve.Feature.Properties);
                }
                // set gameObject transform
                go.name = ve.Feature.Data.Id.ToString();
                go.transform.localPosition = met;
                go.transform.localScale    = Constants.Math.Vector3One;

                if (!_options.scaleDownWithWorld)
                {
                    go.transform.localScale = Vector3.one / tile.TileScale;
                }
                return;
            }
            else
            {
                go = Instantiate(_options.prefab);
                _prefabList.Add(go);
                _objects.Add(ve.GameObject, go);
            }

            go.name = ve.Feature.Data.Id.ToString();
            go.transform.position = met;
            go.transform.SetParent(ve.GameObject.transform, false);
            go.transform.localScale = Constants.Math.Vector3One;

            settable = go.GetComponent <IFeaturePropertySettable>();
            if (settable != null)
            {
                settable.Set(ve.Feature.Properties);
            }

            if (!_options.scaleDownWithWorld)
            {
                go.transform.localScale = Vector3.one / tile.TileScale;
            }

            if (_options.AllPrefabsInstatiated != null)
            {
                _options.AllPrefabsInstatiated(_prefabList);
            }
        }
Example #2
0
        public void PositionScaleRectTransform(VectorEntity ve, UnityTile tile, GameObject go, Vector2d latLong)
        {
            go.transform.localScale = _options.prefab.transform.localScale;
            RectTransform            goRectTransform;
            IFeaturePropertySettable settable = null;
            var latLongPosition = new Vector3();
            var centroidVector  = new Vector3();

            foreach (var point in ve.Feature.Points[0])
            {
                centroidVector += point;
            }
            centroidVector = centroidVector / ve.Feature.Points[0].Count;

            latLongPosition   = Conversions.LatitudeLongitudeToUnityTilePosition(latLong, tile.CurrentZoom, tile.TileScale, 4096).ToVector3xz();
            latLongPosition.y = centroidVector.y;

            go.name = ve.Feature.Data.Id.ToString();

            goRectTransform = go.GetComponent <RectTransform>();
            if (goRectTransform == null)
            {
                go.transform.localPosition = centroidVector;
            }
            else
            {
                goRectTransform.anchoredPosition3D = centroidVector;
            }
            //go.transform.localScale = Constants.Math.Vector3One;

            settable = go.GetComponent <IFeaturePropertySettable>();
            if (settable != null)
            {
                settable.Set(ve.Feature.Properties);
            }

            if (_options.scaleDownWithWorld)
            {
                go.transform.localScale = (go.transform.localScale * (tile.TileScale));
            }
        }
Example #3
0
        public void PositionScaleRectTransform(VectorEntity ve, UnityTile tile, GameObject go)
        {
            RectTransform            goRectTransform;
            IFeaturePropertySettable settable = null;
            var centroidVector = new Vector3();

            foreach (var point in ve.Feature.Points[0])
            {
                centroidVector += point;
            }
            centroidVector = centroidVector / ve.Feature.Points[0].Count;

            go.name = ve.Feature.Data.Id.ToString();

            goRectTransform = go.GetComponent <RectTransform>();
            if (goRectTransform == null)
            {
                go.transform.localPosition = centroidVector;
                if (_options.scaleDownWithWorld)
                {
                    go.transform.localScale = _options.prefab.transform.localScale * (tile.TileScale);
                }
            }
            else
            {
                goRectTransform.anchoredPosition3D = centroidVector;
                if (_options.scaleDownWithWorld)
                {
                    goRectTransform.localScale = _options.prefab.transform.localScale * (tile.TileScale);
                }
            }

            //go.transform.localScale = Constants.Math.Vector3One;

            settable = go.GetComponent <IFeaturePropertySettable>();
            if (settable != null)
            {
                settable.Set(ve.Feature.Properties);
            }
        }