Example #1
0
        private static void MigratePO(string filename, XMLExternalMod mod)
        {
            foreach (Texture image in mod.pattern)
            {
                string picture = SearchMultipleExtensions(IOHelper.ConvertFileToDir(filename) + "\\" + image.pattern);
                if (File.Exists(picture))
                {
                    ModPattern newCandidate = ScriptableObject.CreateInstance <ModPattern>();
                    newCandidate.Name        = mod.name;
                    newCandidate.Author      = mod.creator;
                    newCandidate.Description = filename;

                    if (picture.EndsWith(".tga"))
                    {
                        newCandidate.Main_Texture = TGALoader.LoadTGA(picture);
                        mods.Add(newCandidate);
                    }
                    else
                    {
                        try {
                            byte[]    fileData = File.ReadAllBytes(picture);
                            Texture2D tex      = new Texture2D(2, 2);
                            tex.LoadImage(fileData);                     //..this will auto-resize the texture dimensions.
                            newCandidate.Main_Texture = tex;
                            mods.Add(newCandidate);
                        } catch {
                            Debug.LogError("Could not open the picture: " + picture);
                        }
                    }
                }
            }
        }
        public override bool Equals(object other)
        {
            if (other == null)
            {
                return(false);
            }

            ModPattern tex   = (ModPattern)other;
            bool       equal = this.Main_Texture.imageContentsHash.Equals(tex.Main_Texture.imageContentsHash);

            if (equal)
            {
                Debug.Log("Two matching patterns were found by " + this.Author + " and " + tex.Author);
            }
            return(equal);
        }