Exemple #1
0
        public List <ReferenceImage> LoadImages(string craftID)
        {
            //Debug.Log ("LoadingImages...");
            CraftImagesData images = GetImages(craftID);

            if (images != null)
            {
                List <ReferenceImage> ReferenceImages = new List <ReferenceImage> ();
                foreach (ReferenceImageData image in images.ImageList)
                {
                    try {
                        Texture2D RefImage = new Texture2D(0, 0);
                        RefImage.LoadImage(File.ReadAllBytes(Mod.Instance.RefImagePath + image.ImageName));
                        RefImage.name = image.ImageName;

                        ReferenceImages.Add(new ReferenceImage(image.View, RefImage, null));
                        ReferenceImages.Last().UpdateValue("OffsetX", image.OffsetX);
                        ReferenceImages.Last().UpdateValue("OffsetY", image.OffsetY);
                        ReferenceImages.Last().UpdateValue("Scale", image.Scale);
                        ReferenceImages.Last().UpdateValue("Rotation", image.Rotation);
                        ReferenceImages.Last().UpdateValue("Opacity", image.Opacity);
                        if (ReferenceImages.Last().Active != image.Active)
                        {
                            ReferenceImages.Last().Toggle();
                        }
                    } catch (Exception e) { Debug.LogError("Image Error: " + e); }
                }
                return(ReferenceImages);
            }
            //Debug.Log ("Images null");
            return(null);
        }
Exemple #2
0
        public void SaveImages(string craftName, List <ReferenceImage> images)
        {
            try {
                CraftImagesData ImageData = GetImages(craftName);
                if (ImageData != null)
                {
                    ImageDB.CraftImagesList.Remove(ImageData);
                }
            } catch (Exception e) { Debug.Log("Existing CraftImagesData check failed: " + e); }

            List <ReferenceImageData> _ImageList = new List <ReferenceImageData> ();

            foreach (ReferenceImage image in images)
            {
                _ImageList.Add(new ReferenceImageData()
                {
                    View      = image.View,
                    Rotation  = image.Rotation,
                    OffsetX   = image.OffsetX,
                    OffsetY   = image.OffsetY,
                    Scale     = image.Scale,
                    Opacity   = image.Opacity,
                    Active    = image.Active,
                    ImageName = image.Image.name
                });
            }

            ImageDB.CraftImagesList.Add(new CraftImagesData()
            {
                CraftName = craftName,
                ImageList = _ImageList
            });
        }