Start a new topic

Changing the ImageResource at runtime

Changing the ImageResource at runtime


I'm trying to play with the sample IR code and not getting very far. What I would like to do is change the ImageResource associated with an ImageDrawable, and in turn associated with a Trackable2DObject. - in response to user action at runtime. I can't really statically define these.

What is the approved approach to doing this? Is it possible to reach in and change this constructor parameter at runtime (I'm somehow doubting it)? Can you change the ImageResource assocated with an ImageDrawable? Is there some other way?


Hmm, obviously nobody else has had to change an image at runtime then - strange, I would have thought it was a common requirement.


it is possible to change the ImageResource of an ImageDrawable after it was created.



var imageDrawable = new AR.ImageDrawable(imageResourceOld, 5);
imageDrawable.imageResource = imageResourceNew;


Addtionally if you want to position the drawable differently you might prefere creating 2 imageDrawables and setting disabling one. If the user clicks you can enable the 2nd and disable the first. Use


imageDrawable1.enabled = false;
imageDrawable2.enabled = true;


for this.


We include an API reference with the SDK so you can lookup the mentioned properties and get more detailed info on each.

Login or Signup to post a comment