Change image sprite at runtime

It’s grayed out for me

by user 401167615826984963

Ok its the same issue as in 2022 then :slightly_smiling_face: we track that here: Discord

@positlabs just pushed the new version with the sprite changes :slightly_smiling_face:

awesome! What is the recommended way to upgrade? Can I just reimport the new version on top of the old one?

by user 401167615826984963

Via the package manager

You can also check the ExportInfo component, in the bottom will a button show up informing you that we have an update (hold ALT before clicking to install directly)

Also, I started exploring how to do resize handlers for sprites. I got something kind of working, but it seems like there’s some automagical stuff going on and I don’t know how to react to it. I’m basically just trying to recreate the “background-size: cover” from CSS. needle-audioviz-scrubber/Needle/MainScene/src/scripts/audioviz.ts at master · positlabs/needle-audioviz-scrubber · GitHub

by user 401167615826984963

It’s working but I’m getting complaints from vscode. Maybe the typedefs need to be updated?

by user 401167615826984963

setTexture is still private but you can set the sprite now directly

this.image.sprite = …

like you had it before :slightly_smiling_face:

oh got it, cool

by user 401167615826984963

I am getting some weird errors now

by user 401167615826984963

What is the code that is generated in the cs files?

by user 401167615826984963

Ah wrong type. You can override it via //@type UnityEngine.Image (add as comment above @serializable() for example)

What typescript code did produce that output?

  @serializable(Image)
  image: Image = new Image()

by user 401167615826984963

Ah, why ‘new Image()’?

Just so it was defined and I don’t have to do undefined checks everywhere

by user 401167615826984963