[SOLVED] Changing image through attributes?

So I am trying to make a profile picture selection and I want to do it through attributes. How do I do this?

It won’t work when I do…

Theboard.attributes.add("Pic",{type: 'asset',title: "The ingame image"});
Theboard.attributes.add("Img_one",{type: 'asset',title: "Image 1"});
Theboard.attributes.add("Img_two",{type: 'asset',title: "Image 2"});

Theboard.prototype.initialize = function() {

  this.Pic.button.on('click', this.changepro, this);   


Theboard.prototype.changepro = function () {

if(this.Pic.texture == this.Img_two){this.Pic.texture = this.Img_one;}
if(this.Pic.texture == this.Img_one){this.Pic.texture = this.Img_two;}

I am trying to make it toggle between the two but idk how help please?

Where do you want to apply the texture? Is this an element or a material?


Hey if I all of a sudden stop replying it is because testing is gonna happen in 20-30mins

I’m not sure if you can change an asset at runtime. Can you share your project so I can see your setup?

sure I’ll message you the link
(i don’t want people lookin at my stuff you know)

1 Like

Two things. You have to use this.Pic.element.texture and you have to use this.Img_one.resource. It only changed the first time, so you have to check your statements. (Unfortunately I don’t have time for this at the moment).

ok :+1:

thanks i’ll try that.

Hey it worked!

thank you

1 Like

Good work so far! I like the design.