Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

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:
    464
    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:
    464
  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:
    209
    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:
    209