Search Unity

How to code iPhone controls

Discussion in 'iOS and tvOS' started by flapsion, Jan 4, 2012.

  1. flapsion

    flapsion

    Joined:
    Nov 4, 2011
    Posts:
    3
    Hello Unity this is my first post.

    I want to code a game but how do I code iPhone and Android controls into my game? Is it the same thing or do I have to make 2 games with Android controls and one game with iPhone controls ? :)

    -Flapsion
     
  2. login4donald

    login4donald

    Joined:
    Jan 3, 2012
    Posts:
    462
    It's quite similar, Unity has documentation on that, I'm fairly new at it but it depends on what you wanna do.
     
  3. login4donald

    login4donald

    Joined:
    Jan 3, 2012
    Posts:
    462
  4. flapsion

    flapsion

    Joined:
    Nov 4, 2011
    Posts:
    3
    I will try :) Thank you for reply :D
     
  5. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    220
    Here is what I did for a simple side to side tilt that runs on iOS and Android.

    Code (csharp):
    1.  
    2. if (Application.platform == RuntimePlatform.Android)
    3. {
    4.     Debug.Log("Android");
    5.     _acceleration.x = -Input.acceleration.y;
    6. }
    7. else
    8.     _acceleration = Input.acceleration;
    9.  
    The x on Android seems to be the y on iOS and inverted. However you can us the Application.platform to find out what OS the user is running and make things work that way. Also works for ads, gamecenter etc.
     
  6. flapsion

    flapsion

    Joined:
    Nov 4, 2011
    Posts:
    3
    Okay :) Thank you I will maybe ask later but for now I will need to learn more coding and try to make my first game with the Unity Game Engine, but what way do you think is the best way to earn money on your games?

    Advertising or sell them for about 1$ in Android and iPhone app store. Because Advertising will earn you money all the time, but if you sell your app you only get that 1$ one time + Google and Apple is charging %.

    -Flapsion
     
  7. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    220