Author Topic: How to find UI in runtime?  (Read 4506 times)

noob22

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 38
    • View Profile
How to find UI in runtime?
« on: July 02, 2012, 12:15:54 AM »
Do I need to use U3D's API "FindChild"?It's not efficient!
Any suggestion?

burtonposey

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: How to find UI in runtime?
« Reply #1 on: July 02, 2012, 12:35:02 AM »
How many times do you need to find it? In most cases you should, at most, need to find it once and then store a reference to it in a class variable of whatever script you are trying to utilize it.

noob22

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 38
    • View Profile
Re: How to find UI in runtime?
« Reply #2 on: July 02, 2012, 12:52:42 AM »
How many times do you need to find it? In most cases you should, at most, need to find it once and then store a reference to it in a class variable of whatever script you are trying to utilize it.
Thanks for your reply!
If I need to clone much UI sprite at random position.Sometimes they are visiable and sometimes they are invisiable.Do I use "Instantiate" and "Destroy"?It is not efficient!Any suggestion?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to find UI in runtime?
« Reply #3 on: July 02, 2012, 01:04:19 AM »
Implementation details can vary greatly with what you're trying to do and the complexity of your UI. As Burton said though, find what you need once, and store the reference. Instantiate/destroy can be replaced with enable/disable instead.

noob22

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 38
    • View Profile
Re: How to find UI in runtime?
« Reply #4 on: July 02, 2012, 02:23:39 AM »
Implementation details can vary greatly with what you're trying to do and the complexity of your UI. As Burton said though, find what you need once, and store the reference. Instantiate/destroy can be replaced with enable/disable instead.
Thanks for your reply!I have got it.