Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

question GUItext, root, components

Discussion in 'Scripting' started by dacloo, Jan 30, 2006.

  1. dacloo

    dacloo

    Joined:
    Jun 30, 2005
    Posts:
    469
    Hi,

    I'm full of questions! Sorry :)

    1.
    How do I, e.g from a script attached to a cube, display a GUItext?
    E.g: myCamera.main.GUIlayer.GUItext.text = "Hi there";
    doesnt work.

    2.
    How do I change global game settings? For example, I want the physics to
    perform faster (step) and so forth. Isn't there some sort of "root", or where do I change such things?

    3. These components are awesome. I'm wrote my particle engine in the past by code, now it's a matter of visually setting up. Woooah.
    But...can I write my own components? Or...?

    4. How can I look through the main camera in scene-view? This way I can position it "WYSIWYG"

    Best,

    Jeroen
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    1. Make new gui text.
    In the script you attached to cube, make a reference to the gui text you created.

    Code (csharp):
    1.  
    2. var someText : GUIText;
    3.  
    4. someText.text = "Hi there";
    5.  
    Then select the cube, and drag the gui text game object onto someText slot in the inspector.

    2. Most of those settings are in Edit->Project->
    Time, Player, Physics etc.
    Most of them are also available from scripting, eg.
    Code (csharp):
    1.  
    2. Physics.gravity = Vector3.zero;
    3.  
    3. Essentially by writing scripts you are writing components. You can easily create scripts that are generally useful and reusable.
    Make sure to expose useful properties to the inspector so you can easily tweak the script behaviour.

    When you start out using unity, it is easiest to just let scripts do exactly what you need for a specific purpose. Once you really get the hang of unity you can start writing more reusable code.
    But really, game code isn't that reusable most of them time.
     
  3. dacloo

    dacloo

    Joined:
    Jun 30, 2005
    Posts:
    469
    Thanks Joachim!

    I didn't know about that project settings menu option...all clear.

    Text is working. I thought I had to create a GUItexture, and then
    place text on that texture, but in facts, that is being done for me
    in the background :)

    Last thing: how do I delete objects from the hierarchy window?
    I used Finder for now, but I read Finder is a big no-no because
    of references being lost.

    I had this weird problem: I added a shadow blob, removed it with the
    Finder, but it still was there :-/
     
  4. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    cmd-delete or use the menu command Edit->delete
     
  5. dacloo

    dacloo

    Joined:
    Jun 30, 2005
    Posts:
    469
    Thanks. Wouldnt it be more consistent to provide DELETE through a right-click contextual menu choice, just like the project view does?
     
  6. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    The project view's context menu doesn't have such a context menu item.

    The cmd-delete pattern is a very standard User Interface element on the mac.
    It works exactly the same way in the finder and all other applications that follow Apple's Human Interface Guidelines.
     
  7. Scandalon

    Scandalon

    Joined:
    Aug 25, 2005
    Posts:
    44
    Suggestion: Project view *should* have delete contextual menu, as should the hierarchical menu. (I too had to hunt for the cmd-delete menu option). Note the finder has a "Move to trash" contextual option.
     
  8. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    I don't think this one got answered so...

    You position your scene view how you want the camera to be, then you select the camera and click GameObject->Align With View on the top menu. That will move the camera to the same position as the view.

    -Jeremy