Search Unity

Divisions always return an int. (SOLVED!)

Discussion in 'Scripting' started by Whalepork, Jan 19, 2015.

  1. Whalepork

    Whalepork

    Joined:
    Sep 4, 2013
    Posts:
    18
    [Deleted]
     
    Last edited: Mar 8, 2017
  2. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    try this:
    Code (charp):
    1. 1.0f * Screen.width / Screen.height;
     
    Whalepork likes this.
  3. Shiikarii

    Shiikarii

    Joined:
    Feb 6, 2014
    Posts:
    89
    i belive Screen.width & height is an integer you could write:

    Code (CSharp):
    1. Debug.log ((float)Screen.width / (float)Screen.height);
     
    Whalepork likes this.
  4. Whalepork

    Whalepork

    Joined:
    Sep 4, 2013
    Posts:
    18
    Thank you, that worked like a charm :)
     
  5. Shiikarii

    Shiikarii

    Joined:
    Feb 6, 2014
    Posts:
    89
    no problem ;)