Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GameObject.transform.position gonna cause low effeciency ?

Discussion in 'Scripting' started by ZorroBlade, Sep 2, 2014.

  1. ZorroBlade

    ZorroBlade

    Joined:
    Jul 7, 2011
    Posts:
    25
    Today, I heard an interesting advice from my friend. He said that :

    u don't call GameObject.transform.position in Monobehavior.Update() ,
    because GameObject.transform equals Transform trans = GameObject.GetComponent<Transform>() ;

    so that would cause low effeciency ... then he show me lots of example in NGUI code ...
    And he told me to cache a GameObject.transform reference at the very beginning..
    I really doubt that, can any one explain that ?

    thanks a lot.
     
  2. ZorroBlade

    ZorroBlade

    Joined:
    Jul 7, 2011
    Posts:
    25
  3. THoeppner

    THoeppner

    Joined:
    Oct 10, 2012
    Posts:
    205
  4. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369