コード例 #1
0
ファイル: NewIcon.cs プロジェクト: MCJack123/Unity2DE
    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);
    }
コード例 #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;
            }
        }
    }