Skip to main content
ExoGuid
Honored Contributor
May 1, 2025
Solved

Workaround for ImageBinding in Array

I have some non-interactive CUIs prefabs (instances) running the same script and am swapping an image from an array.  It was working fine until I had to make the bindings private.

Array:

const imagesarray = [
  ImageSource.fromTextureAsset(new TextureAsset(BigInt(1341929837137421))),
  ImageSource.fromTextureAsset(new TextureAsset(BigInt(1021032403421524))),
  ImageSource.fromTextureAsset(new TextureAsset(BigInt(1013325437401914))),
];

 

index Binding:

 myindex = new Binding(0)

 

imageBinding(fromArray)

let myindex = 0
const myimageBinding = new Binding(imagesarray[myindex]);

 

onupdateHUD

myindex = (persistentStorage.getPlayerVariable<number>(player, "MYPPID"));

 

The issues mainly arise in the imageBinding(fromArray) line of code when I set everything to private.

1) can't use a binding for an index

2) can't use a BigInt for an index (thought I could just adjust the imagesource in my UI Image

3) unable to import/use "derive" or "derivebinding"

Been trying some things but if anyone has a workaround please lmk.

ExoGuid
ExoGuidAnswer
Honored Contributor
May 1, 2025

I figured it out.

I created private bindings, removed the index variable and replaced it with the getPlayervariable.

 private imageBinding = new Binding(images[0]);

 

new method for updating the binding

this.myimageBinding.set(images[(persistentStorage.getPlayerVariable<number>(player, "MYPPID")) % images.length]);

 

 

 

1 reply

ExoGuid
ExoGuidAuthorAnswer
Honored Contributor
May 1, 2025

I figured it out.

I created private bindings, removed the index variable and replaced it with the getPlayervariable.

 private imageBinding = new Binding(images[0]);

 

new method for updating the binding

this.myimageBinding.set(images[(persistentStorage.getPlayerVariable<number>(player, "MYPPID")) % images.length]);