transform.Translate vs transform.position +=

Оптимизация кода.

transform.Translate vs transform.position +=

Сообщение [bm] 06 дек 2012, 09:53

В чем конкретная разница между transform.Transalet(offset) от просто transform.position += offset ? Интересно что происходит в transform.Transalet(offset). Знаю что только transform.position += offset быстрее.
Mafia Rush: universal iOS game _https://goo.gl/CKq4D Android _https://goo.gl/slFLXx
Shooter Ball: Android _https://goo.gl/21QyPw
skype: bmindfield
Аватара пользователя
[bm]
UNIверсал
 
Сообщения: 426
Зарегистрирован: 11 май 2010, 22:33
Откуда: Россия, Ижевск

Re: transform.Translate vs transform.position +=

Сообщение seaman 06 дек 2012, 15:47

методы в движке такие:
Синтаксис:
Используется csharp
        public void Translate(Vector3 translation)
        {
            Space self = Space.Self;
            this.Translate(translation, self);
        }
        public void Translate(Vector3 translation, Space relativeTo)
        {
            if (relativeTo == Space.World)
            {
                this.position += translation;
            }
            else
            {
                this.position += this.TransformDirection(translation);
            }
        }
        public void Translate(Vector3 translation, Transform relativeTo)
        {
            if (relativeTo != null)
            {
                this.position += relativeTo.TransformDirection(translation);
            }
            else
            {
                this.position += translation;
            }
        }
        public void Translate(float x, float y, float z)
        {
            Space self = Space.Self;
            this.Translate(x, y, z, self);
        }
        public void Translate(float x, float y, float z, Space relativeTo)
        {
            this.Translate(new Vector3(x, y, z), relativeTo);
        }
        public void Translate(float x, float y, float z, Transform relativeTo)
        {
            this.Translate(new Vector3(x, y, z), relativeTo);
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        internal extern void SendTransformChangedScale();
        public Vector3 TransformDirection(Vector3 direction)
        {
            return INTERNAL_CALL_TransformDirection(this, ref direction);
        }
        public Vector3 TransformDirection(float x, float y, float z)
        {
            return this.TransformDirection(new Vector3(x, y, z));
        }
 


Т.е. все сводится к некоей внутренней функции public Vector3 TransformDirection(Vector3 direction), написанной на плюсах.
seaman
Адепт
 
Сообщения: 8352
Зарегистрирован: 24 янв 2011, 12:32
Откуда: Самара


Вернуться в Код

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1


cron