Updates to Unity

Update 8 : GUI Text / Textures

As of Unity 4.6 there is a new UI system in Unity. I thoroughly encourage you to go and learn it with the tutorials my team has been producing at http://unity3d.com/learn – BUT please wait until you’ve completed the book.

Now I could go and make a series of videos editing individual parts of the book to implement the new UI tools and make a series of changes, but really it would make things complicated, and in actual fact what I’d recommend is that you take the book’s route to finishing it’s tutorial, then go learn the new systems. This should avoid confusion then allow you to immediately upgrade your skills.

So for now, when the book asks you to add a GUITexture or GUIText object, do the following –

Top menu > Game Object > Create Empty

Top menu > Component > Rendering > GUITexture (or GUIText)

This will create the same game object as the previous shortcut from the Create Other menu used to as the book describes. I may go back and open the book’s project in Unity 4.6 or 5.0 and make a video about upgrading the book’s project after the fact, but in reality i’m pretty busy writing the 5x version of the book, sorry that’s not so helpful for some of you.

Thanks again to all of you for your patience with the book and me in updating you all.

Update 7: Animation Looping

As of Unity 4.3, Animation works differently thanks to a new relationship with the Animator system in Unity – the state machine added in Unity 4.0. The only point this effects animation in the book is where clips loop. Now, by default, all animation clips are looped. For things like the fading GUITexture in the scene transitions at the end of the book, we need looping not to occur. To solve this, once your animations are created, simply locate them in the Project panel, and select them, then in the inspector, uncheck the ‘Loop Time’ property which is checked by default.

unity how to stop looping animation

Update 6: Terrain settings

As of Unity 4.2, Unity’s Terrain creation and editing settings have been moved. Now, to Create a Terrain, go to the top menu and choose GameObject > Create Other > Terrain.

unity create a terrain

Then to access settings of the terrain, such as its scale, select the Terrain in the Hierarchy, and in the Inspector, click the Cog Icon on the Terrain component – not the one in the top right of all components, but the last one in the row of Terrain editing buttons –


Update 5: Target settings

Some users have written to suggest that their Animated targets detect collisions but do not animate. Please check your settings against the screenshot below.


Update 4: Unity 4.x Import Settings for Models

Due to a few changes in the import pipeline since the book’s release, you’ll need to change how the import of models is setup when introducing them into the book, but fear not, here is a unity package with the book assets setup with all the correct new settings!

Any issues, please comment below.

Download 4.x Unity Book Package w/ Import Settings

Update 3: Unity 4.1

In Unity 4.x there is a new way of setting up animations for models. To setup the outpost, select it in the Project panel and in the Inspector, choose the Animations tab at the top. Then create clips using the Clips table – first rename Default Take to ‘idle’ and make the first clip, simply drag the in and out point handles together to get a single frame.

Then click the + button to add the other two animations, but note that the range for doorshut will end up being 16 to 29. When you’re done, it should look like the image below –

Screen Shot 2013-04-12 at 12.50.07

Take the same approach to setting up animations for the Coconut Targets later in the book.

Update 2: Unity 4.0

This book was written when Unity 3.4 was released. With the release of 4.0 recently, I can now confirm that the book still works fine in this version, though you should still note the first update’s details below!

Update 1: Unity 3.5

This book was written at the time when Unity 3.4 was released. Unity 3.5 features some significant changes, and a few of these effect what occurs in the book.

Chapter 8 – Particle Systems.

This chapter leads you through creating a campfire. In Unity 3.5 there is a new particle system, so I have provided the following video to show you how to make the campfire with the new system, and then how to integrate in the Inventory script afterwards.

Stop reading Chapter 8 at Page 283, then follow the video. In the video, I mention a download of 2 texture files, which you can grab here.

93 thoughts on “Updates to Unity

    • Hi Jon, I work for Unity so I designed the book as much as possible with 3.5 in mind. There is very little change needed to work with the book and Unity 3.5. The only change that really effects things is the new particle system. For this I will post a new video tutorial on this site soon covering how to make the same fire, and what to change in scripts later. However, for now, the old particle system is still in Unity 3.5, you simply need to do the following to create a system –

      GameObject > Create Empty.
      Component > Effects > Legacy Particles > Ellipsoid Particle Emitter.
      Component > Effects > Legacy Particles > Particle Animator.
      Component > Effects > Legacy Particles > Particle Renderer.

      This will make you a Particle System that is the same as the original System that the book asks you to make. Then you can carry on following the book as usual.

  1. Hi Will, I bought your book via Amazon and can’t say enough about it. My 8 year old even loves the simple prototype game. I’ve gained all kinds of confidence and can’t wait to get started on my game idea of a Monopoly type board game. I’m pretty good with Blender, so it’s really a matter of figuring out Unity. Anyway, my question. I’m making my way through the part where the shy targets are added. I have no problem getting the Instantiation script for the coconuts to work, I can throw them, I have no problem with anything else, but have come to a halt on the Targets. I can’t get the targets to knock down, play the sound, etc. I attached my Target Collision Script below, but wonder if it is a problem with the Animations in the Inspector or maybe one of the Collision settings. Any help you can provide would be appreciated. Anyone reading this who is considering the book…..GET IT…..don’t take my questions to Will as a negative review…I’m taking as much time as I can muster to learn Unity and have no prior scripting knowledge. It’s likely me. 🙂

    Target Collision Script
    #pragma strict

    private var beenHit : boolean = false;
    private var targetRoot : Animation;
    var hitSound : AudioClip;
    var resetSound : AudioClip;
    var resetTime : float = 3.0;

    function Start() {
    targetRoot = transform.parent.transform.animation;
    function OnCollisionEnter(theObject : Collision){
    if (beenHit==false && theObject.gameObject.name==”coconut”){

    function targetHit(){
    audio.PlayOneShot (hitSound);

    yield new WaitForSeconds(resetTime);

    audio.PlayOneShot (resetSound);
    @script RequireComponent(AudioSource)

    • Hi Steve, not sure what you’re doing wrong here but its not to do with Unity updates I would say. Can you mail me a screenshot of your setup and any error messages you get when playing the game – Also, you have definitely applied the script to the child ‘target’ object right? I sometimes write a script and then actually forget to assign it and press Play!

      • Hi Will, Thanks for the reply. I have the script attached to the child Target and the animations are attached to the parent’s, parent (TargetPrefab is the name in my case). I have some screenshots for you and will send them to you. It’s almost as if it doesn’t like this function…….>
        function Start() {targetRoot = transform.parent.transform.parent.animation;

        or maybe there is a problem with my co routine call. It’s actually a great learning experience trying to figure this out. 🙂

        • Hi Will and Steve,

          I am now actually facing the same problem. The target does not play the ‘up’ and ‘down’ animations once it is hit by the coconuts.

          I did a simple ‘debug.Log(“test”);’ test right at the start of the ‘onCollisionEnter’ function and realize the program doesn’t go into this collision function.

          Did you get your problem solved? Thanks.

          • Hi all, I have solved my silly mistake. The reason why when the coconut and target collided with each other but the OnCollisionEnter function was not executed, that’s because of a spelling mistake.

            It should be OnCollisionEnter instead of onCollisionEnter. The ‘O’ issue. Thanks.

          • Yes always check Case Sensitive stuff – that goes for your comment about debug.Log too, it should be Debug.Log.

          • Hi all,
            I did have a similar problem that wasn’t due to any spelling mistake, my coconut simply didn’t collide with the target in some situations. I found that by setting the collision mode of the coconut on “Continuous” instead of “Discrete” this solved the issue. Just thought I’d mention it if someone with a similar problem came by 🙂

  2. (C4: Deconstructing the script) Is there a C# version?

    Hi Will. I’m currently reading chapter four, and have encountered a motor script that you have detailed that’s only referenced in JavaScript. Is there a C# version on your web site, or available in the asset package? There’s no mention. C# is the programming language I’ve been following in the book as I already have experience with it.

    Regards, Rigel

    • Hi Rigel, I haven’t converted the code to C# actually but I can provide that. Give me a little while and i’ll post it on this site.

  3. Hi Will, I refer to your chapter 11, ‘Performance Tweaks and Finishing Touches’. There is a small issue after I baked my scene. The game object, ‘Door Light’, that’s supposed to turn green after player collected all the power cells and near the door, will not not turn green anymore. I have checked that it is not marked as static.

    Is your side having the same outcome? Thanks.

    • Hey Aaal Goh,

      Not sure if you managed to fix the problem you were having. I had the same problem and fixed it by changing the lightmapping for the Door Light to “RealtimeOnly” before you bake. This can be found under the “Object” tab” under the Lightmapping panel. Make sure “Door Light” is selected in the Heirarchy panel.

      Btw, thanks for writing a great book Will, it was incredibly useful.


  4. Hi, thanks for this book, I am a beginner and it is working wonders for me!. The only problem I have is that I reached Chapter 5, so I here I downloaded the assets folder to import the outpost 1444EXP_Code.zip, then when unzipped I get book_assets.unitypackage.zip then if I try to unzip that one or just import that one directly to Unity, I get a folder full of subfolders with weird numbers, each with 4 files called metaData, pathname, preview (a png file image, asset preview) and asset (a Unix executable file kind), I already tried all possible ways to import it, would this be happening because I am on a Mac? Thanks.

  5. I just purchased this book about a week ago. I have been trying to solve some problems, but the web site was down all week. I tried posting in the Unity forums, but was unsuccessful. Glad to see the web site up and running.
    Here are the problems I’ve run into.

    I have Unity 3.5.5 installed.

    On page 143 setting up the outpost model there are a few differences in the book compared to what I’m experiencing.

    It lists a step to go Under Materials-Generation and set it to Per Texture.
    I don’t have a generation drop down box to set, it only has Import Materials,Material Naming and Material Search.
    Is this something that is no longer in the software?

    Secondly in the table based area under animations there is only
    one entry in the table
    In the book there is

    Are there updated resources for use with Unity 3.5.5?

    Lastly the FBXImporter component in the Inspector, I don’t see the actual name “FBXImporter” anywhere how do I know if that is what I’m using when looking in the inspector?


    • Hi Sean!

      Sorry for my slow response, I’ve been away, also sorry for the site downtime. Anyway – to answer your queries.

      Page 143

      Set Materials to its default – Import Materials should be checked, and Material naming set to By Base Texture, and Search set to Recursive up.

      As for the animations – re-read the passage, its asking you to click the + icon and create those animations, the image is there to show you the frame ranges – apologies if this wasn’t clear!

      Regarding ‘FBXImporter’ – this title was simply dropped in favour of ‘Import Settings’. No practical change involved!

      • Thanks for setting me straight. I think after being unable to find the materials drop down box i stopped reading and just happened to notice the animations table picture didn’t match mine. I jumped the gun a little on that one.

        I’m looking forward to finishing this awesome book!

  6. The line from your video:
    … doesn’t work for me. There error I get is “unexpected token:).”

    I’m using JavaScript and notice that in the video you are using C#. Is it possible there’s a syntax issue?

    It is a great book, by the way. I’m using it to teach an independent study and am lobbying for an entire course on Unity.

    • Michael – you’ve probably just got a typo, there isn’t a syntax difference I don’t think, can you pastebin.com the code and send the link in a comment? i’ll take a look.

  7. Here’s the link: http://pastebin.com/x0ACikdR and thanks for the help.

    I’m pretty good at spotting typos in ActionScript when my students make them, but if this is one, I can’t see it. I teach a games class with Flash and will spend a couple of weeks introducing Unity so kids can see the difference. My only real concern is that they won’t want to go back to Flash.

    Thanks again.

    • You’ve not written which Type of component to get – you’ve removed the <> in converting to Javascript but also removed ‘ParticleSystem’!

      should be –


  8. Also I get an error saying:
    HDR RenderTexture format is not supported on this platform. This camera will render without HDR buffers.

    • The HDR processing on cameras was new in Unity 3.5. To remove the error (which is a Warning, really, not an error) simply select your camera, and in the Camera component, uncheck ‘use HDR’.

  9. Hello,

    I’ve been a bit stuck in chapter 10 page 370-371 where the objective is
    to add an animation for the Loading GUI. I’m trying to make the 4 key frames

    seconds position y
    0 -1
    1:00 0.5
    4:00 0.5
    5:00 -1

    And it is simply not adding the key frames for me.
    I was wondering if this is a Unity Version issue in some way or if I’m just
    doing it wrong. I’m using Unity version 3.5.6

    Any help would be greatly appreciated, Thanks

    I screen captured exactly what I’m doing here if it’s ok

    • I was finally able to duplicate the shape of the curve for this animation after viewing your animation window tutorial on unity3dstudent.com

      The difference was I learned that you can double click the line to add a key frame instead of using the add key frame GUI button. Although even double clicking wasn’t working every time. What seems to happen sometimes is the last point gets updated instead of a new point being created.
      Probably user error rather than the software itself.

  10. I am having some problems with the coconutShy. Here is my coding as per the book along with the error I am getting.

    #pragma strict

    private var beenHit : boolean = false;
    private var targetRoot : Animation;
    var hitSound : AudioClip;
    var resetSound : AudioClip;
    var resetTime : float = 3.0;

    function Start () {
    targetRoot = transform.parent.transform.parent.animation;

    function Update () {


    function OnCollisionEnter(theObject : Collision) {
    if(beenHit==false && theObject.gameObject.name==”coconut”){

    function targetHit(){
    beenHit = true;

    yield new WaitForSeconds(resetTime);

    beenHit = false;

    @script RequireComponent(AudioSource)

    MissingComponentException: There is no ‘AudioSource’ attached to the “target” game object, but a script is trying to access it.
    You probably need to add a AudioSource to the game object “target”. Or your script needs to check if the component is attached before using it.
    UnityEngine.AudioSource.PlayOneShot (UnityEngine.AudioClip clip) (at C:/BuildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/Editor/BaseClass.cs:504)
    TargetCollision+$targetHit$1+$.MoveNext () (at Assets/Scripts/TargetCollision.js:24)
    TargetCollision:OnCollisionEnter(Collision) (at Assets/Scripts/TargetCollision.js:19)

  11. Is this update compatibile with ver. 4 of Unity ? Or it needs to be updated for 4.0.0. I’m curretly using v. 4.0.0 and i don’t know if i have to uninstall it and go for 3.5 for better compatibility with this book.

  12. I am facing problems with loadingGUI thing… I have tried removing the animation and creating it again several times, but never gets what it is intended… The “Loading…” texture may be moving in diagonal, also making an S, or not be shown at all. The thing is that I am not changing nothing but Y position curve as told in the book, but it seems like X where arbitrary changed also for some reason.

    Does anyone experimented such problems? Any ideas?

      • I have done it three times, deleting everything related, and it does not move as expected, instead of that the Loading… text appear closed to the lower left corner of the screen, moves in diagonal to the center of the screen, and from there it moves straight to the left until it disappears, and after that it returns straight to the center of the screen, and then goes down straight until it disappears at the bottom.

        In the animator there are no keys on X at all, at least I do not see them. I have shared you a screenshot of the animation window anyway through Google Plus.

  13. Hi there again,

    I have reached chapter 11, but it seems things related to volcano smoke and particle system are also outdated as chapter 8, as I have created a particle system but it doesn’t has Ellipsoid Particle Emitter nor Particle Animator neither.

    Any hints on this?

    Thanks a lot in advance,

  14. Hi again,
    I’m busy with the Loading GUI animation (pages 370 up) and I’m having an issue getting the Loading GUI to display. It only works if I modify the z position value of my loadingGUI prefab.
    Apparently the loadingGUI is instantiated behind the fade object. Is this a normal thing? Because I don’t see this mentioned anywhere in the book.

  15. Hi Will. Thanks for making update for Unity 3.5 Particle System. I must say that whole book is very, very awesome, I learnt from it much new things and solutions to improve game projects with Unity. Thank you so much.

  16. I’m having a problem in the section “Creating the menu with the Unity GUI class and GUI skins”. None on the menus show up in the Game screen when I Play the game. And onGUI() is never called. hmmm….

  17. Love the book, made a huge jump forward in my programming. Would recommend this book and have to anyone getting started with unity.

  18. Hello,
    I’m working through the Unity Game Development Essentials book, and am having trouble locating the “outpost”. I does not appear in my standard assets. I’m working in 4.1.2 – is this a known issue? Is there somewhere I could download the model? It does not appear to be in the Asset Store.

    • Hi Joe – all you’ve done there is managed to find the site.. but miss the Downloads area 😉 This is where the bundle for the book is, or you can get it from the book’s publisher’s site as written in the book – this site is preferred though. It’s nothing to do with Standard assets, these are tools provided by Unity tech directly.

      • Okay, I feel like an idiot. I saw that page but thought the download graphic was pointing to the glossary link. I could have, you know, read the words, but who has time for that!?
        In the interm I managed to import a sketchup file instead, so that’s something.
        Book is awesome btw, (so far).

  19. Hi,

    I have bought and followed your excellent book up to adding inventory to the player portion. It is here that I have encountered an error that I cannot solve.

    When I play test the game with the power cells scattered near the outpost and with all of the scripts (in C#) properly attached and compiled, the sound for cell pickup does not work. In other words, when I walk over a power cell and pick it up, the cell is picked up and the object is destroyed, but no pickup sound is played.

    I have checked and re-checked all of the scripts, I have also made sure that the scripts are attached to all of the proper elements in the editor (as well as making sure that the actual sound clip is attached to the right property) and yet except for the overall ambient sound, no other sounds are played when I pick up a power cell. Is there something I am doing wrong here or am I forgetting to add something in the code?

    I am using Unity v4.1.2f1 if that helps.

    Thanks in advance,


    • Hey Max can you throw me the related scripts into pastebin.com and reply with the links via this comment thread? Should be simple enough to diagnose. Thanks for the detailed explanation of your issue btw, like it when I read an eloquent report like that!

        • These look just fine! Did you apply the tag “Player” to the player? Did you set the audio clip to 2D or 3D? Tried reimporting the clip or applying a different clip to the script to play instead as a test?

          • Hi Will,

            Thank you once again for all your help. I have tested the game again and have tried setting the sound to 2D instead, but it still did not work.

            However, while testing the game again, I have noticed the “SendMessage to CellPickup() has no receiver” error message that your book mentioned – I thought that that is strange, as that error message should have been cleared once all of the scripts have been attached and compiled before.

            Apparently, my Inventory script had the function CellPickup written with a lower case p and not capital P, while the call to CellPickup was looking for a function with the capital P in its name, which caused this whole malfunction in the first place.

            So, thank you for your help and let me apologize for this whole post – it looked effectively like a typo on my end (I guess I should have been paying more attention to the code). From now on I will try not to use the Shift key when typing anymore 🙂 .

  20. Hi Will,

    Unfortunately, I have run into yet another issue, this time with the coconut game – just like the first person that commented above. I too have an issue with the instantiated coconut object hitting but not animating the target in the shack.

    I have checked the spelling and the scripts several times over and made sure that everything is attached as per your book. All of the sound files have been attached to proper elements as well and I have even run the game with the console window open at the same time – there were no errors or warnings reported and yet the target animation still does not play when a coconut hits it.

    As per “jeango’s” comment I have also switched the collision detection on the coconut prefab from Discreet to Continuous (as initially the coconuts in my game were going right through the target without hitting it at all) and although the coconuts are hitting the target properly, the animation of the target object still does not play.

    Here is the pastebin.com link to my copy of the TargetCollision script:


    I have tried several other things like adding this script to the first target in the Hierarchy instead of the actual target model, also to no avail. I almost got a feeling that the collision between the coconut and the target does not lead to the animation playing on the target object, like there is no call from the scripts to enable the animation once a hit has been registered between these objects.

    Additionally, I am beginning to get a sneaky suspicion that the command to disable collisions between the coconut object and the player collider might have something to do with this particular problem…


    • Hi Max, I’ve added an update to the Updates to Unity page I think may help you – its more of a tip, but worth checking out. If that doesn’t solve your issue, try downloading the Unity 4 version of the assets I also posted to the Downloads page today. All the best!

    • Hey, I had the same problem that you are having. I found that I had to manually add the audio source to the targets even though the script was supposed to take care of that for us. Once i added the audio source, the game worked perfectly fine. Thanks for the great book Will!

  21. on the 4.x downloads my outpost looks completely different than the original outpost? Is this intended, or am i missing something? thanks!

  22. I would like to thank Will for the video on particles in Unity 4. It’s funny that I’ve learned about this website already after completing the Particles chapter (by using legacy particles), but still I was very pleased to found here your smart video on how to make the campfire with Unity 4. Taking the opportunity, I’d like to ask you a small question, which is puzzling me. When in the game I come up to a palm tree it changes its view from like 2D to real 3D (like a flower reveals) and this doesn’t look too natural. Is it should be this way or may be I need to make some tweaks to the camera or renderer settings? Thanks in advance!

    • that’s detail distance I think – take a look at the terrain settings, you can define stuff like this there I believe. Either way the terrain system and that tree in particular are not great assets. They are some of the weaker parts of Unity that Unity Tech are currently working on updating.

      • Yes, Will, thank you! The thing affecting this issue is “Fade Length” parameter of the “Tree & Detail Objects” group in the Terrain settings.

  23. I am teaching a Game Programming & Design class to high school students and using your book as my guide. We are working on collisions in chapter 5 of your book and I have a few students whose door’s won’t open. Not sure where the issue is, find the script below, any input of what might be issue would be greatly appreciated.

    using UnityEngine;
    using System.Collections;

    public class playercollision : MonoBehaviour {
    bool doorIsOpen = false; //used to determine if door is open
    float doorTimer=0.0f; // time that has passed since door was opened
    public float doorOpenTime=3.0f; //amt time door should stay open
    public AudioClip doorOpenSound;
    public AudioClip doorShutSound;

    // Use this for initialization
    void Start () {


    // Update is called once per frame
    void Update () {

    void OnControllerColliderHit(ControllerColliderHit hit){
    if(hit.gameObject.tag==”playerDoor” && doorIsOpen==false){ //if run into door and not already open
    OpenDoor(hit.gameObject); //call instructions to open door

    void OpenDoor(GameObject door){ // function to open door


  24. Hello Will,
    I’ve just finished the book using the latest Unity 4.3. I’d like to say thank you for the support and updates for Unity 4. This really keeps the book usable even for the latest Unity version.
    The book is really good. It is definitely easy to follow (I got lost a little bit in chapter 9, but that is nothing). Overall it is great stuff. Well done!
    I’ve completed many books in the past mainly on the web development but never felt so happy to go to another chapter as in your book. Transitions from one chapter to chapter are in my mind ideal. That is really important. Not many books I read had it!
    All I can say it’s 5 out of 5 stars from me. Thank you very much.

  25. Let me start off by saying I absolutely love this book. I’m posting from my tablet since my PC currently has no internet connection so I’m not including complete code. Unity ver: 4.3.2f1

    I’ve been troubleshooting like some other users a while back with the coconut shy animation refusing to play. None of the game objects are static and to the best of my knowledge the case sensitive is correct. I believe my issue lies in this line:

    targetRoot = transform.parent.transform.parent.animation;

    I have been receiving this error during play when I hit the target with a coconut:

    UnityEngine.Animation.Play (System.String animation)

    I used the updated asset package that was posted here.

    Here is the function for targetHit:

    beenHit = true;

    yield new WaitForSeconds(resetTime);

    beenHit = false;

    There may be typos in the code I posted since autocorrect doesn’t seem to like javascript. I’ll definitely post from an actual PC next time and copy/paste my code as its written in Unity. I believe the problem lies in the targetRoot variable we use as a reference in my current release of Unity. Thank you

    • Update:
      Whenever I commented out the ‘targetRoot’ and just replaced ‘targetRoot.Play’ with ‘transform.parent.transform.parent.animation.Play’ the animations worked just fine.

  26. Hello. Will there be a new book for the latest version of Unity????? Or should I start with this one, and have in mind the changes in this page?


    • My new book will be for version 5 but it won’t be ready til mid next year, this book should still work, there aren’t any huge changes.

  27. It would appear in 4.6, there is a completely new UI interface that does not jibe with “Creating the matches GUI” on p296. I’ve been meddling with a series of things but can’t seem to find a solution. What do you suggest?

  28. Hi, I am at Chapter 6 and am having trouble with Unity v4.6.0f3. I cannot find a way to make a GUITexture out of the hud_nocharge texture:

    Creating the GUITexture object
    While this is technically a three-step procedure, it can be done in a single step by
    selecting the texture to be used in the Project panel, and then going to GameObject
    | Create Other | GUITexture from the top menu. Do this now.

    Please help 🙂

    • This component is now under Rendering, hope that helps. I will also be making a video on how to replicate what is in the book with the New UI tools at some point I just haven’t had time yet. For now you can make an Empty game object and add that component to continue the book’s instructions.

      • I.vote.for.this(LOL);
        Brilliant book.
        While workaround is logical (create empty GameObject [Ctrl-Shift+N], Add Component* / Rendering / GUITexture (* [Ctrl+F] for Search and type ‘guit…’, click-select or Down arrow+[Enter]), attached textures (to public fields in Inspector) appear stretched (or squeezed and off screen) if I change resolution in Game window and play [Ctrl+P].
        Workaround – set Scale and Position in Inspector to suitable values (for X and Y axes).
        I wonder if this is correct workaround or am I missing something?

        Best regards,

      • I ran into the same issue and more; I figured out my alternative for making text. Create an instance of the new Text class (under UI) instead of the older GUIText, put it in the hierarchy, and rename that TextHintsGUI as per the book. Extend the receiving script (TextHints) from the Text Class instead of MonoBehavior. Go back to the TextHintGUI item in the hierarchy and replace the Text component on there with your TextHints script. You then just have to change the code in the TextHints and TriggerZone scripts to reflect the fact that your textHints variable is now of type TextHints. Seems to work so far.

      • I’m stuck at the same page. I added an empty game object, then added a GUITextture component with the corresponding hud_nocharge asset (texture type=”Editor GUI and Legacy GUI”), but I can’t see anything on scene exepted the object’s axis… Please help asap.

        • Agreed, this solution on the top of this page for creating empty game objects and then adding GUITexture through Component -> Rendering does not work for the Crosshairs. All I see is a blank axis where the object is supposed to be. Even with the crosshairs texture highlighted and even after I added it as the GUITexture’s “Texture” value, nothing carries over onto the new GameObject. I am assuming setting the Crosshairs texture type to “Editor GUI and Legacy GUI” is the way to go for Unity 4.6? Still doesn’t work, though.

          • As an alternative, I found that applying the Crosshair texture as a 2D Sprite, then creating the GameOject as 2d -> Sprite, and dragging the crosshair into the Sprite component of that, worked. The call you have to make in the code is then crosshair.renderer.enabled = true (or false)

  29. Sorry to be a recurring pain, but one important thing to add to the changes is that GUISkins have been 100% eliminated — as in, no replacement, other than using prefabs.

    I also found it pretty much impossible to go through the book using the legacy GUITexture options, as they just didn’t come out right, especially in the menus. Overall, I had to look into the new UI options and just use Images, Buttons and event triggers that called the functions in Will’s code remotely (after making those functions public).

    With buttons, I found that you can delete the default button text and button graphic and just use the regular and rollover graphics as children, if you wrap them into Image objects. (apply the regular and rollover textures as 2D Sprites, then drag them into Images)

  30. In Chapter 5, p 180 of print edition of the book, it says you can use Shift-Drag to resize and reposition the box collider, however this doesn’t seem to do anything related to the collider (using Unity 5.2.2p3). With the Hand Tool selected (as specified on that same page), and holding down Shift will not show any collider boundaries for the collider. Dragging in this mode with Shift down will just do what dragging without Shift did (move around the camera). Manipation of the box collider is still possible via the inspector. Is this something that changed?

  31. Page 58 Problem with unassigned reference. On the page it refers to assigning a prefab projectile to bullet variable in the shooting script assigned to the main camera by dropping the projectile onto bullet variable in inspector, if assigned correctly the name of projectile will replace no Rigidbody Assigned. I have done this and followed the instruction to the letter and Projectile has replaced the previous message but I still get below error and I can’t see any code mistakes:

    Error Message:
    UnassignedReferenceException: The variable bullet of Shooter has not been assigned.
    You probably need to assign the bullet variable of the Shooter script in the inspector.
    UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineObjectBindings.gen.cs:51)
    UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Shooter : MonoBehaviour {
    public Rigidbody bullet;
    public float power = 1500f;
    public float moveSpeed = 2f;

    // Update is called once per frame
    void Update () {
    float h = Input.GetAxis (“Horizontal”) * Time.deltaTime * moveSpeed;
    float v = Input.GetAxis (“Vertical”) * Time.deltaTime * moveSpeed;
    transform.Translate (h,v,0);

    if (Input.GetButtonUp (“Fire1”)) {
    Rigidbody instance = Instantiate (bullet, transform.position, transform.rotation) as Rigidbody;
    Vector3 fwd = transform.TransformDirection (Vector3.forward);
    instance.AddForce (fwd * power);

    Please can you help?

    Kind Regards


Leave a Reply

Your email address will not be published. Required fields are marked *