Exemplo n.º 1
0
    public Texture2D LoadPNG(string filePath)
    {
        Texture2D tex = null;

        byte[] fileData;
        if (File.Exists(filePath))
        {
            fileData = File.ReadAllBytes(filePath);
            tex      = new Texture2D(2, 2);
            tex.LoadImage(fileData); //..this will auto-resize the texture dimensions.
            tex = LauncherAppIcon.Resize(tex, 48, 48);
        }
        return(tex);
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        string textureString = PlayerPrefs.GetString("Wallpaper");

        if (textureString != "")
        {
            XmlSerializer xmlDeserializer = new XmlSerializer(typeof(Wallpaper));
            using (TextReader reader = new StringReader(textureString)) {
                Wallpaper retval;
                try {
                    retval = xmlDeserializer.Deserialize(reader) as Wallpaper;
                } catch (Exception e) {
                    Debug.LogError("Could not load wallpaper from XML: " + e.Message + ".\nXML: " + textureString);
                    return;
                }
                texture = new Texture2D(48, 48);
                texture.LoadImage(retval.data);
                texture      = LauncherAppIcon.Resize(texture, Screen.width, Screen.height);
                textureIsNew = true;
            }
        }
    }