Author Topic: Changing an Atlas assigned to a UISprite?  (Read 4202 times)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Changing an Atlas assigned to a UISprite?
« on: September 08, 2012, 07:41:33 AM »
How do I do this?

So far I have assigning new sprites in an atlas. Using something like this:-

mySprite.spriteName = "other_sprite_name";

This all works but now I want to do something like this.
mySprite.atlasName = "other_atlas_name";

I have searched around on this forum and found .replacement

But I can't seem to get it to work. I have loaded two atlases like this:-

UIAtlas myAtlas1 = Resources.Load("mydir/myAtlas1", typeof(UIAtlas)) as UIAtlas;
UIAtlas myAtlas2 = Resources.Load("mydir/myAtlas2", typeof(UIAtlas)) as UIAtlas;

Then I call my atlas change.

mySprite.atlas.replacement = myAtlas2;


However if I debug the atlas (mySprite.atlas), it is still pointing to myAtlas1.

Am I missing something obvious?

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Changing an Atlas assigned to a UISprite?
« Reply #1 on: September 08, 2012, 08:32:30 AM »
Ok, fixed it now. That is a weird one.

Seems all I needed was

mySprite.atlas = myAtlas2;

Not sure what replacement does but it didn't seem to do anything for me.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing an Atlas assigned to a UISprite?
« Reply #2 on: September 08, 2012, 03:11:34 PM »
Replacement atlas feature is used for atlas swapping on mobile platforms when you need SD / HD / UD atlases. There is a video tutorial on how to use it.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Changing an Atlas assigned to a UISprite?
« Reply #3 on: September 09, 2012, 01:27:03 AM »
Aah, that would make sense. I searched and found that video tutorial. Thanks for that :)