Example #1
0
        private void SpawnPrefab(VectorEntity ve, UnityTile tile, Vector2d latLong)
        {
            GameObject go;

            var featureId = ve.Feature.Data.Id;

            if (_objects.ContainsKey(featureId))
            {
                go = _objects[featureId];
                go.SetActive(true);
                go.transform.SetParent(ve.GameObject.transform, false);
            }
            else
            {
                go = Instantiate(_options.prefab);
                _prefabList.Add(go);
                _objects.Add(featureId, go);
                _objectPosition.Add(featureId, latLong);
                go.transform.SetParent(ve.GameObject.transform, false);
            }

            PositionScaleRectTransform(ve, tile, go, latLong);

            if (_options.AllPrefabsInstatiated != null)
            {
                _options.AllPrefabsInstatiated(_prefabList);
            }
        }
Example #2
0
        public override void Run(VectorEntity ve, UnityTile tile)
        {
            if (_options.prefab == null)
            {
                return;
            }

            GameObject go = null;

            if (_objects.ContainsKey(ve.GameObject))
            {
                go = _objects[ve.GameObject];
            }
            else
            {
                go = Instantiate(_options.prefab);
                _prefabList.Add(go);
                _objects.Add(ve.GameObject, go);
                go.transform.SetParent(ve.GameObject.transform, false);
            }

            if (go != null)
            {
                PositionScaleRectTransform(ve, tile, go);
            }

            if (_options.AllPrefabsInstatiated != null)
            {
                _options.AllPrefabsInstatiated(_prefabList);
            }
        }
        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);
            }
        }
        public override void Run(VectorEntity ve, UnityTile tile)
        {
            GameObject go = null;

            if (_objects.ContainsKey(ve.GameObject))
            {
                go = _objects[ve.GameObject];
            }
            else
            {
                go = Instantiate(_options.prefab);
                _prefabList.Add(go);
                _objects.Add(ve.GameObject, go);
                go.transform.SetParent(ve.GameObject.transform, false);
            }
            go.name = ve.Feature.Properties["title"].ToString();
            PositionScaleRectTransform(ve, tile, go);

            if (_options.AllPrefabsInstatiated != null)
            {
                _options.AllPrefabsInstatiated(_prefabList);
            }
        }
        private void SpawnPrefab(VectorEntity ve, UnityTile tile)
        {
            GameObject go = new GameObject();

            if (_objects.ContainsKey(ve.GameObject))
            {
                go = _objects[ve.GameObject];
            }
            else
            {
                go = Instantiate(_options.prefab);
                _prefabList.Add(go);
                _objects.Add(ve.GameObject, go);
                go.transform.SetParent(ve.GameObject.transform, false);
            }

            PositionScaleRectTransform(ve, tile, go);

            if (_options.AllPrefabsInstatiated != null)
            {
                _options.AllPrefabsInstatiated(_prefabList);
            }
        }