Author Topic: Vector3.one and Vector3(1,1,1)  (Read 1007 times)

Elapse

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Vector3.one and Vector3(1,1,1)
« on: March 28, 2018, 08:28:42 AM »
Hi there,

I want to change the Buttons scale in two ways in different situations. For one way it works fine:

//when I start the menu
//position changes aswell

TweenScale tweenS = prefab.GetComponent<TweenScale>();
      tweenS.from = Vector3.zero;
      tweenS.to = Vector3.one;   <-----why Vector3(1,1,1) instead leads to an error? how to fix it?
      tweenS.PlayForward();

The Problem is, that I need to change the values to Vector3(1.5, 1.5, 1.5) for the next way. The Unity API says that Vector3.one is just a short version of Vector3(1,1,1). I'm confused.

Thanks for help and have a good day. Marten

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,153
  • Toronto, Canada
    • View Profile
Re: Vector3.one and Vector3(1,1,1)
« Reply #1 on: March 29, 2018, 12:00:50 PM »
Zero is an invalid scale. You can't divide by zero, so inverse transform can't be calculated. You're shooting yourself in the foot whenever you use a zero scale. Consider changing it to 0.001 instead.

Your question is also not an NGUI question, and not even a Unity question, but a basic C# question. In C# you need to prefix new object declarations with a "new".

Elapse

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Vector3.one and Vector3(1,1,1)
« Reply #2 on: April 03, 2018, 04:28:09 AM »
Thanks for "taping" :)

I wonder, why it works then, but I'll change it and try fading them out and in instead.