Search Unity

[SOLVED] GUI and iPhone

Discussion in 'Immediate Mode GUI (IMGUI)' started by jwalduck, Aug 31, 2009.

  1. jwalduck

    jwalduck

    Joined:
    Aug 16, 2009
    Posts:
    11
    I read on a blog somewhere that for performance reasons you should use GUI Text and GUI Textures for iPhone displays rather than UnityGUI.

    Can someone confirm this?

    If so can anyone point me at a tutorial/reference for GUI Text that takes me through how to get it working?

    From the reference documentation I know I need a GUILayer on the camera, and the GUI Text can be attached to an empty game object.

    I have tried multiple times to get this working just using the frames per second script from the 3D tutorial in my own project. I cannot get the FPS to display in a webplayer or stand alone build.
     
  2. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Confirmed. The OnGUI immediate mode GUI system uses more drawcalls (primary bottleneck on the iPhone) than GUITextures.

    http://unity3d.com/support/documentation/Components/class-GuiTexture.html

    This is relevant for in-game GUI where you're hunting FPS. For menus, OnGUI will be just fine.

    A lot of people also make use of the SpriteManager library for 2D graphics on the iPhone.

    http://www.unifycommunity.com/wiki/index.php?title=SpriteManager

    Regarding the FPS script, people will need a little more information to go by in order to solve your problem. For reference, theres also an FPS script using GUIText available here:

    http://www.unifycommunity.com/wiki/index.php?title=FramesPerSecond
     
  3. jwalduck

    jwalduck

    Joined:
    Aug 16, 2009
    Posts:
    11
    Thanks for those links. I had found the GUITexture one already and found it to be very unhelpful for someone just starting out.

    The FPS script linked to above is the exact one I am using (JS version) though I got mine from the 3D platformer tutorial.

    Here is what I have set up:
    1. I have a camera in my scene with the GUILayer component.
    2. I have a gameObject at location 0,0,0 (I have also tried it right in front of the camera) with a GUIText component and the FPS script.
    3. I have set a Font and Material on the GUIText component. The Anchor is set to Centre Middle.

    I still get no text displayed on screen in either the editor scene view or web player.

    What am I doing wrong?
     
  4. jwalduck

    jwalduck

    Joined:
    Aug 16, 2009
    Posts:
    11
    I am still having no luck with this. Can anyone give me some advice on how to get this working?
     
  5. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Is there any chance you could post the project? It's probably a really easy solution, but it's difficult to guess from your description what is going on.
     
  6. duck

    duck

    Unity Technologies

    Joined:
    Oct 21, 2008
    Posts:
    358
    Check that the gameobject in question isn't parented to anything - if it is, then even though its position is 0,0,0, its parent's position may be throwing it off-screen.

    Also check that you haven't accidentally hidden it using camera culling layers.

    - Ben
     
  7. raleighr3

    raleighr3

    Joined:
    Jul 9, 2008
    Posts:
    106
    Try getting the simplest possible case working first.

    Add a new GUIText object to your scene: Game Object -> Create Other -> GUI Text

    Now set the position to (0.5, 0.5, 0.0), Rotation (0,0,0) Scale (1,1,1). Don't set the Pixel Offest X,Y in the gui text inspector. THis will center the Text in the view.

    Does it show now? If it does great! If not then something is wonky, double check GUILayer is enabled on the Main Camera, and that the Layer of the GUIText isn't being culled.
     
  8. jwalduck

    jwalduck

    Joined:
    Aug 16, 2009
    Posts:
    11
    Thanks raleighr3.

    Setting the X,Y to 0.5,0.5 did the trick. I can now see how the X,Y coords relate to the screen position.

    Thanks also to everyone else for the their help.