Search Unity

A few Questions from a new user

Discussion in 'Editor & General Support' started by astrospoon, Mar 23, 2009.

  1. astrospoon

    astrospoon

    Joined:
    Mar 23, 2009
    Posts:
    16
    Hey-- Learning Unity and am mighty impressed. Just a few questions.

    Question 1:

    When I download some of the sample projects people have online, and try to run them they never work. I just downloaded the "2DShooter" project, and when I try to run I get these errors:

    BCE0153: 'UnityEngine.RequireComponent' can be applied on one of these targets only : Class.

    shoot2.wav failed to import (Unity does not support .wav files with more than 16 bits per sample)
    -- Why would the project include a sound that can't be played?

    Blender could not be found
    -- This error is shown twice. Why would I need Blender installed to run a Unity project? Doesn't Unity open these files on its own?

    Question 2:


    My second question has to do with my project. I set up a Orthographic camera, and I want to create a textured Plane that is the exact height and width of the viewport box, so it is displaying the image on it full screen. However, I can't figure out how to scale a Plane in a function.

    The Transform component has functions to Translate and Rotate... why is there no Scale function?

    How can I get the height and width of the Camera's Viewport in World space so I can scale a Plane to match it?

    Thanks!
    Andy
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Some of them are kind of old and were written for Unity 2.0 or earlier.

    For example, this is a typo that Unity used to silently ignore, but now it rightfully complains. ;) It's supposed to be "@script RequireComponent(GUIText)".

    Because it could be played at the time. Actually I guess that must be a Windows limitation because it still works fine on my Mac using Unity 2.5.

    Only if they're .fbx. Native formats are supported by opening the app in the background and making it export to .fbx.

    transform.localScale = Vector3(2.0, 2.0, 4.0);

    --Eric
     
  3. astrospoon

    astrospoon

    Joined:
    Mar 23, 2009
    Posts:
    16
    transform.localScale = Vector3(2.0, 2.0, 4.0);

    Oh man. When I learned C++ in school they would have killed us for this sort of thing. They were all about the Get and Set style functions for altering an objects variables.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Then I guess you don't want to hear about transform.position = Vector3(whatever), or transform.eulerAngles = Vector3(foo), or transform.rotation = Quaternion(eek). ;) Translate() and Rotate() are fine for relative movement but sometimes you need to set things directly. To heck with book learnin'.... Of course, you can make your own relative Scale() function too, using transform.localScale to implement it.

    --Eric
     
  5. astrospoon

    astrospoon

    Joined:
    Mar 23, 2009
    Posts:
    16
    So can anyone help me with the second part?

    I'm trying to draw a billboard that covers the entire screen with an Ortho camera.

    I found the ScreenToWorldPoint camera function, which means that if I pass it the corner screen coordinates, I should get world points that I can then use as the corner poines for a billboard that will fill the whole screen.

    But... Um... How do I just draw a Rectangular Billboard in Unity? (I am used to OpenGL) If I create a Plane, I cannot pass points to it at all. (Only position and scale). Should I be using a Mesh instead?

    Am I better off positioning a Plane with the center point of the screen, and then scaling it to get the correct size? How would I calculate what scale to use?

    I think there is some larger concept I am missing here....
     
  6. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    Well that would be true for languages that don't have properties. localScale is in fact not an object variable, but a property. (Properties are basically syntactic sugar that makes getter and setter methods look like you are accessing or assigning to a variable.)
     
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Others would kill people for mentioning C hack hack in a modern development community ;)
    So its actually a even situation at least until we take into account that unity uses properties like most C# code does, not ugly freshmen code design class get/set messes ;)
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you have Pro, you can use the GL class, and then use GL.QUADS. Otherwise, yep, you can build a mesh using the Mesh class.

    --Eric