Error Unity: Texture needs to be...

Discussion and help for Easy Save 3

Error Unity: Texture needs to be...

Postby teq » Mon Nov 25, 2019 4:12 pm

Hi there! I'am trying saving list of object(not images, sprites and other) and got this stack of errors
Code: Select all
11.25 18:06:33.419 15336 15463 Error Unity: Texture needs to be marked as Read/Write to be able to GetRawTextureData in player
11.25 18:06:33.419 15336 15463 Error Unity: ES3Types.ES3Type_Texture2D:WriteUnityObject(Object, ES3Writer)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Types.ES3UnityObjectType:WriteObject(Object, ES3Writer, ReferenceMode)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Writer:Write(Object, ES3Type, ReferenceMode)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Writer:WriteProperty(String, Object, ES3Type)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Types.ES3Type_Sprite:WriteUnityObject(Object, ES3Writer)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Types.ES3UnityObjectType:WriteObject(Object, ES3Writer, ReferenceMode)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Writer:Write(Object, ES3Type, ReferenceMode)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Writer:WriteProperty(String, Object, ES3Type, ReferenceMode)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Types.ES3Type:WriteProperties(Object, ES3Writer)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Types.ES3ReflectedObjectType:WriteObject(Object, ES3Writer)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Types.ES3ObjectType:Write(Object, ES3Writer)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Writer:Write(Object, ES3Type, ReferenceMode)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Types.ES3ListType:Write(Object, ES3Writer, ReferenceMode)
11.25 18:06:33.419 15336 15463 Error Unity: ES3Writer:Write(Object, ES3Type, ReferenceMode)
11.25 18:06:33.419 15336 15463 Error Unity: ES3File:Save(String, Object)
11.25 18:06:33.419 15336 15463 Error Unity: UserSettingsManager:SetEs3Save(String, T)
11.25 18:06:33.419 15336 15463 Error Unity: JamPacksScrollRectItemsAdapter:SavePacksState(Boolean)
teq
 
Posts: 15
Joined: Mon Jul 16, 2018 12:23 pm

Re: Error Unity: Texture needs to be...

Postby Joel » Tue Nov 26, 2019 8:07 am

Hi there,

Somewhere in your code you're trying to save a Texture2D. However, to access the Texture's data for saving, you must mark is as readable. You can do this by selecting the Texture and pressing the Read/Write Enabled button, and then pressing Apply.

TextureReadable.PNG
TextureReadable.PNG (33.05 KiB) Viewed 64 times


All the best,
Joel
Joel Tebbett @ Moodkie Interactive
Twitter - Unity - LinkedIn
User avatar
Joel
Moodkie Staff
 
Posts: 2552
Joined: Wed Nov 07, 2012 10:32 pm

Re: Error Unity: Texture needs to be...

Postby teq » Tue Nov 26, 2019 12:21 pm

Joel wrote:Hi there,

Somewhere in your code you're trying to save a Texture2D. However, to access the Texture's data for saving, you must mark is as readable. You can do this by selecting the Texture and pressing the Read/Write Enabled button, and then pressing Apply.

TextureReadable.PNG


All the best,
Joel

Object that i want to save contains only ints, string, floats, and two Sprite. Could the presence of the latter be the cause of the error?
Also, with new Unity 2019.2.13f i faced with strange behavior. When i close Editor without es3DefaultFile.Sync() it takes 3 seconds, but when i add this line to OnDestroy() (singe call) it takes ~ 15s.

P.S. Interesting, that i never catch this before while working with the same list.

Here is my settings
Image
Image

In code i use
Code: Select all
_es3Settings = new ES3Settings(ES3.EncryptionType.AES, "123");
_es3Settings.location = ES3.Location.PlayerPrefs;
...
es3DefaultFile = new ES3File(Es3Settings);


If i use
Code: Select all
_es3Settings.location = ES3.Location.File;

it takes 5s when exit from Editor and save file size is 23mb. Seems it's so huge because i have Sprite references in my saving objects. So can this be a source of issue? I mean user device can't handle this or something like this.

BTW, what's the bigger priority:edtor es3 settings windows or code settings?
teq
 
Posts: 15
Joined: Mon Jul 16, 2018 12:23 pm

Re: Error Unity: Texture needs to be...

Postby Joel » Tue Nov 26, 2019 7:08 pm

Hi there,

This would indeed cause that file size, because Sprites are Textures, so to serialise this will mean seralising the raw texture data for the Sprite.

With regards to settings, the settings provided as a parameter to methods is prioritised over the global settings.

All the best,
Joel
Joel Tebbett @ Moodkie Interactive
Twitter - Unity - LinkedIn
User avatar
Joel
Moodkie Staff
 
Posts: 2552
Joined: Wed Nov 07, 2012 10:32 pm

Re: Error Unity: Texture needs to be...

Postby teq » Wed Nov 27, 2019 12:11 pm

Joel wrote:Hi there,

This would indeed cause that file size, because Sprites are Textures, so to serialise this will mean seralising the raw texture data for the Sprite.

With regards to settings, the settings provided as a parameter to methods is prioritised over the global settings.

All the best,
Joel

Thanks! I have re-written this logic and just saving important fields now, but i want also clear save file from unnecessary Sprite data for old users, who will download an update.
Here is part of that code
Code: Select all
if (es3DefaultFile.KeyExists("old_value_with_lot_sprite_data"))
{
    es3DefaultFile.DeleteKey("old_value_with_lot_sprite_data");
    es3DefaultFile.Sync(Es3Settings);
}


I am expecting that file size have to reduce to 15kb, but it remains the same.
It can be "deleted" only if i rewrite it like savemethod("old_value_with_lot_sprite_data", new List()). I think it would be more clear if with key deletion also deleting associated data.


Btw, after Sync file should i create it again? Or i create it at start, load/save, and sync when i want?
I'm asking because when i Sync and then DeleteKey, on the next start i still have this key.
Let me clear: after key deletion it does not present in keys array, but after sync it is still in file.
teq
 
Posts: 15
Joined: Mon Jul 16, 2018 12:23 pm

Re: Error Unity: Texture needs to be...

Postby Joel » Wed Nov 27, 2019 7:25 pm

Hi there,

This sounds like an issue which is resolved in the next update. I'll PM you the update to try.

All the best,
Joel
Joel Tebbett @ Moodkie Interactive
Twitter - Unity - LinkedIn
User avatar
Joel
Moodkie Staff
 
Posts: 2552
Joined: Wed Nov 07, 2012 10:32 pm

Re: Error Unity: Texture needs to be...

Postby teq » Thu Nov 28, 2019 10:20 am

Joel wrote:Hi there,

This sounds like an issue which is resolved in the next update. I'll PM you the update to try.

All the best,
Joel

May be i should use syncWithFile param with false value?
But i think it works not how i want, it would be ok if i only could delete data on key deletion, so i am going to wait a patch =)
teq
 
Posts: 15
Joined: Mon Jul 16, 2018 12:23 pm

Re: Error Unity: Texture needs to be...

Postby Joel » Thu Nov 28, 2019 6:05 pm

Hi there,

I PM'd you a patch yesterday, did you receive this?

All the best,
Joel
Joel Tebbett @ Moodkie Interactive
Twitter - Unity - LinkedIn
User avatar
Joel
Moodkie Staff
 
Posts: 2552
Joined: Wed Nov 07, 2012 10:32 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron