Search Unity

How would i to see this the Int must be this number or this number Javascript

Discussion in 'Scripting' started by byro210, Oct 20, 2014.

  1. byro210

    byro210

    Joined:
    Feb 18, 2014
    Posts:
    121
    Sorry about the name I didn't know how to explain it in a title.

    Im using JavaScript and I want to know how to make it show a picture if the integer is either 1 or 3 so I get.

    if (PlayerPrefs.GetInt("Map Area")==1)

    but how would I make

    if (PlayerPrefs.GetInt("Map Area")==1) or (PlayerPrefs.GetInt("Map Area")==3)

    it will show my image instead of just the Int being 1? o_O

    Please and thankyou in advance - sorry if it doesn't really make sense im not that good at explaining. :confused:
     
  2. MarksTeq

    MarksTeq

    Joined:
    Oct 20, 2014
    Posts:
    1
    Use the OR operator in JavaScript which is: ||
    So your statement will look like:
    if ((PlayerPrefs.GetInt("Map Area")==1) || (PlayerPrefs.GetInt("Map Area")==3))

    Feel free to read up more on conditional operators at:
    http://www.w3schools.com/js/js_comparisons.asp
     
  3. zDemonhunter99

    zDemonhunter99

    Joined:
    Apr 23, 2014
    Posts:
    478
    Code (JavaScript):
    1. if((PlayerPrefs.GetInt("Map Area")==1) || (PlayerPrefs.GetInt("Map Area")==3))
    2. {
    3. // Insert code here
    4. }
     
  4. byro210

    byro210

    Joined:
    Feb 18, 2014
    Posts:
    121
    Thank you:)