Author Topic: Steps to switch HD/SD at runtime. Approved?  (Read 2658 times)

sisso

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 46
    • View Profile
Steps to switch HD/SD at runtime. Approved?
« on: August 22, 2013, 02:47:41 PM »
After reading around what I need to do to switch the HD/SD at runtime, I finished with this steps:

1.  Instead create the reference atlas as prefab like video tutorial, you need to create the reference atlas in each scene, this will allow you to do changes in runtime.
2.  The script that load the atlas from resources must execute before any ngui stuff. Use awake and script execution order.
3. Before a build, you update each scene the reference atlas to point to null, so the default is loaded in memory.
4. For prefabs with sprites (like popups). You must point to null atlas and resolve when instantiated.

Any advice or better solution? A simple "ok, you are not crazy" is a good answer to me :P

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Steps to switch HD/SD at runtime. Approved?
« Reply #1 on: August 23, 2013, 03:08:12 PM »
Prefabs with sprites point to null? You need 3 atlas prefabs. HD, SD, and Reference. All widgets must use the Reference atlas. Before building, set Reference to point to nothing. In the Awake function, set the reference atlas to point to the SD or HD atlas.

sisso

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 46
    • View Profile
Re: Steps to switch HD/SD at runtime. Approved?
« Reply #2 on: August 23, 2013, 08:05:28 PM »
If the correct way is to use the  3 atlas as prefab. I must change the reference atlas prefab at runtime. I think that I misunderstood unity3d prefabs at runtime "readonly". But it make sense, at runtime, prefabs are simple gameobjects.

Forgot my item 4. It was to be "widgets point to empty atlas". But if I could point to the prefab, it is ok.

Thanks for clarification.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Steps to switch HD/SD at runtime. Approved?
« Reply #3 on: August 25, 2013, 07:49:02 AM »
So, you're only slightly crazy, which is all good. :P

While you cannot change Prefabs directly at runtime, as soon as you instantiate it, you have your own copy which you can change around as much as you want.

Reference atlas should point to null when building and you set the reference to a SD or HD atlas you load from Resources as well.