Пример #1
0
 public void Save(string name, Optional <Image> preview)
 {
     IsSaving = true;
     MapWorker.BuilderMapController.MapHost += (map, isSuccessful, error) =>
     {
         if (isSuccessful)
         {
             var mapMeta = new MapMeta(map, new List <MapMeta.PropInfo>());
             MapMetaManager.Save(mapMeta);
             GUIPopup.EnqueueMessage("Map Generated", 3);
             GUIPopup.EnqueueMessage("Notice: map name can be changed on website," + Environment.NewLine +
                                     "while the SDK side will not get updated until map cache cleared and a re-download has been triggered.", 5);
             Saved = true;
         }
         else
         {
             GUIPopup.EnqueueMessage("Fail to generate Map" + (string.IsNullOrEmpty(error) ? "" : "\n error: " + error), 5);
         }
         IsSaving = false;
     };
     try
     {
         MapWorker.BuilderMapController.Host(name, preview);
     }
     catch (Exception e)
     {
         GUIPopup.EnqueueMessage("Fail to host map: " + e.Message, 5);
         IsSaving = false;
     }
 }
Пример #2
0
        public void Save()
        {
            if (mapData == null)
            {
                return;
            }

            var propInfos = new List <MapMeta.PropInfo>();

            foreach (var prop in mapData.Props)
            {
                var position = prop.transform.localPosition;
                var rotation = prop.transform.localRotation;
                var scale    = prop.transform.localScale;

                propInfos.Add(new MapMeta.PropInfo()
                {
                    Name     = prop.name,
                    Position = new float[3] {
                        position.x, position.y, position.z
                    },
                    Rotation = new float[4] {
                        rotation.x, rotation.y, rotation.z, rotation.w
                    },
                    Scale = new float[3] {
                        scale.x, scale.y, scale.z
                    }
                });
            }
            mapData.Meta.Props = propInfos;

            MapMetaManager.Save(mapData.Meta);
        }