Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Unity Tips Tricks

Discussion in 'General Discussion' started by Noisecrime, Jan 28, 2012.

Thread Status:
Not open for further replies.
  1. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,731
    So despite using Unity for some time I still discover little tricks or features in the editor that can make a developers life easier. Just today I stumbled across creating a GuiTexture whilst a 2D texture is selected not only applies the selected texture automatically but also sets up the pixel inset values!

    So I figured there must be plenty of other little tips or tricks for the editor and thought i'd starta thread for others to add to it. Only 2 rules, firstly it must related to the editor, so no coding tricks or how to use a feature, secondly as a tip it should be quick and simple to do, nothing that requires many complex steps.

    May I also request discussion is kept to a minimum, i.e no arguments over what is a tip and what might be common sense, e.g. camera's can have individual skyboxes. I'd like, assuming there are more tips for this to be a useful resource. I may, time permitting compile all the suggestions into this first post.


    Tips, Tricks Cool features.

    001: Creating a GuiTexture whilst having a 2D texture selected in the 'project pane' will automatically use that texture (instead of the default Unity Logo) and correctly set up the pixel inset values.

    002: Camera's can have their own skybox via adding the skybox component to any camera.

    003: Cubemaps are never compressed in vram (ARGB32) (standalone/web player), for skyboxes you are better off using 6 compressed textures if memory is an issue.

    004: Use [] around important gameObject names or append an underscore to the beginning to place them at the top of the hierarchy.

    005: Project Wide Defines - See here.

    006: Holding down "Ctrl" you can drag a object one block at a time.

    007: Have the scene camera in an awesome position and want to move the game camera to match?
    -Select the camera in the hierarchy then GameObject -> Align With View

    008: Want to move the scene camera to the position of the main camera?
    -Select the main camera then GameObject -> Align view to selected

    009: Create a material with the shader you want to use highlighted in the project browser it will use the selected shader by default.

    010: FBX Scale Fix Automatically add colliders - See Silence post.

    011: Delete inspector array items (like the input manager) by clicking on the item and pressing cmd-delete (or the Windows equivalent - think that is just delete).

    012: You can insert into inspector array items by selecting an item and hitting cmd-d to duplicate.

    013: FBX - select embed media when exporting your fbx files. The textures will then be placed into a seperate folder, which will be linked to your model automatically when imported into Unity.
     
    Last edited: Jan 31, 2012
    Demigiant and SememeS like this.
  2. recon

    recon

    Joined:
    Nov 28, 2009
    Posts:
    119
    I think this thread is a great idea :)

    A little trick I use is to put [ ] clauses around important gameobject names, this way they always show up at the top in the Hierarchy because of alphabetical sorting. That way It's easier to find my important gameobjects when Im testing my game :p
     
  3. recon

    recon

    Joined:
    Nov 28, 2009
    Posts:
    119
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,351
    Well, except that's not true. Skyboxes are compressed, and they would never have worked on cards with low VRAM otherwise.

    --Eric
     
  5. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,731
    Interesting I've always been partial to adding an underscore before a name to get it to the top of the hierarchy.

    That's what I said, cubemaps aren't compressed. In standalone and webplayer they are ARGB32, so don't use them for skyboxes, use the 6 textures method instead.
     
    Last edited: Jan 28, 2012
  6. Goolygot

    Goolygot

    Joined:
    Jul 11, 2011
    Posts:
    35
    While holding down "Ctrl" you can drag a object one block at a time. It makes building levels much faster if you've made models to fit exactly that way.
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,351
    I thought you were saying skyboxes aren't compressed, but I see you're talking about cubemaps specifically.

    --Eric
     
  8. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,165
    Have the scene camera in an awesome position and want to move the game camera to match?
    -Select the camera in the hierarchy then GameObject -> Align With View

    Want to move the scene camera to the position of the main camera?
    -Select the main camera then GameObject -> Align view to selected

    If you create a material with the shader you want to use highlighted in the project browser it will use the selected shader by default.

    Do you want some extra editor functionality you think would be really awesome? Learn the editor scripting API's... you can do so so much with them!
     
  9. Silence

    Silence

    Joined:
    Jul 9, 2011
    Posts:
    98
    Annoyed by the 0.01 import scale factor? Want to automatically add colliders?
    Well...now you can.
    Code (csharp):
    1. using UnityEditor;
    2.  
    3. public class FBXScaleFix : AssetPostprocessor
    4. {
    5.     public void OnPreprocessModel()
    6.     {
    7.         ModelImporter modelImporter = (ModelImporter) assetImporter;                    
    8.         modelImporter.globalScale = 1;        
    9.         modelImporter.addCollider = true;
    10.         modelImporter.normalImportMode = ModelImporterTangentSpaceMode.Calculate;
    11.  
    12.     }  
    13. }
    14.  
     
  10. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,731
    Some great tips, keep em coming.

    Really could have done with the scene/game camera alignment tip a few days ago ;)
     
  11. Sock Puppet

    Sock Puppet

    Joined:
    Jan 9, 2011
    Posts:
    77
    Always like tip threads.

    Here's mine - you can delete inspector visible array items (like the input manager) by clicking on the item and pressing cmd-delete (or the Windows equivalent). You can also insert by selecting an item and hitting cmd-d to duplicate.

    I went an embarrassingly long time before realizing this.
     
  12. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    When I first started importing FXB models, they would import without their textures.

    Importing the image files before the fxb file solved this problem.
     
  13. larvantholos

    larvantholos

    Joined:
    Oct 29, 2009
    Posts:
    668
    Even better than this, if you select embed media , you'll export your fbx files, with their texture, into unity, in a seperate folder, which will be linked back up to your model automatically.
     
  14. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,731
    Thanks,

    Have added the additional tips to the OP.

    Any more?
     
  15. insominx

    insominx

    Joined:
    Jan 23, 2012
    Posts:
    32
  16. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    Insominx - I'm using the Movie Textures right now, and your procedural geometry one was a lifesaver on my last project (in sig). Thanks for making the solutions to real problems, real simple to follow.

    Gigi.
     
  17. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,731
    Great video's and tutorials but generally those aren't really the tips tricks I refer to here.

    Tips Tricks in this thread are for lesser known features, shortcuts and abilities of Unity that most developers will never stumble upon, they may not even be in the documentation at all.

    However your colour picker video is a perfect example of the sort of thing that would have gone into this thread. It took a while for myself to realise you could click the ink dropper and access anything on screen.
     
    Last edited: May 23, 2013
  18. JustinWhite

    JustinWhite

    Joined:
    Apr 11, 2013
    Posts:
    36
    Ok, this one is a productivity thing. When developing for mobile, keep the screen-size in standalone. Change the standalone size via a editor extensions script. i.e I have a "iPhone 3GS" button that changes the screen size and aspect ratio to that device. Same with iPhone 4 and iPhone 5... Particularly useful when using NGUI. Obviously use a landscape check-box to switch between landscape and portrait. Use aspect ratios or extend with other device pixel sizes.

    Edit: There should be a picture here :(

    $guiios.jpg
     
    Last edited: May 24, 2013
  19. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    Can you explain? I've no idea what you're talking about.
    Gigi
     
  20. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,731
    At a random guess they may have been referring to using a script like this from the docs.

    I never realised you can set the defaultScreenWidth/Height for both standalone and web from scripts. It even works to change them in Awake() from a script. This is pretty useful for the cases Justin points out, but also for me where I have projects which contain lots of little projects and frequently require a specific screen size. Used to be i'd have to keep going into edit>player settings>player to change them, but using these functions in a script seems to be a perfect solution.

    Of course you'll have to be careful of script order and any other scripts which require using screen width/hieght to ensure its changed before they run.


    e.g.
    Code (csharp):
    1.     public  int     _screenWidth;
    2.     public  int     _screenHeight;
    3.  
    4.     void Awake ()
    5.     {  
    6.         PlayerSettings.defaultScreenWidth =  _screenWidth;
    7.         PlayerSettings.defaultScreenHeight = _screenHeight;    
    8.     }
     
    Last edited: May 25, 2013
  21. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,692
    Sorry, I do not know this part.
    What is that for?
    Any URL to read to understand what does "Project Wide Defines" mean?
     
  22. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,731
    It used to be that defines were only scoped to the script they were defined in, meaning if you wanted to use them to control all scripts within a project, you'd have to add the define to each script. This was of course impractical and frustrating since defines are normally project wide specially to do this. The link simply described a method to enforce defines as being 'project wide' (or at the project scope) i.e. when a define was set it would be applied to all scripts.

    However since Unity 4 or 4.1 I believe these are now supported via the edit>player settings>player>scripting define symbols. So there is probably no need for this any more.
     
  23. jasperstocker

    jasperstocker

    Joined:
    Jul 7, 2010
    Posts:
    428
  24. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,529
    Ive got a small one (so to speak). If you wish to set all materials to the same one, instead of going through each one manually you can observe the size of the material array. Lets say its 20, set the top material to the one you want, then set the materials array size to 1. Then set it back to 20, and it has set all materials to the same one for you. This one saves me a lot of time :)

    Im looking in particular for a quick way to drag and drop in the hierarchy window. Im trying to move a huge scene with many things into other game objects, so I can turn whole areas on and off, but the dragging in the hierarchy window is unbelievably slow which makes this task a nightmare. But as of yet I know no tricks to speed it up!.

    Great tips on this thread thanks.
    Gaz.
     
  25. hagish

    hagish

    Joined:
    May 18, 2014
    Posts:
    10
Thread Status:
Not open for further replies.
unityunity