Unity 5 support

Home Forums Books Mastering Unity 2D Game Development Unity 5 support

This topic contains 7 replies, has 2 voices, and was last updated by  Leonardo 2 years ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #6749

    As I’ve commented on Facebook and numerous places, this title fully supports Unity 5.

    To date there is only 1 warning generated by upgrading to Unity 5 regarding the application of Mecanim for the Battle AI machine, updating this couldn’t be simpler:

    1. Open the BattleManager script (BattleManager.cs)
    2. Find line 174 in the Update() function
    3. Replace “.nameHash” with “.fullPathHash” so that line 174 now reads:

    “currentBattleState = battleStateHash[battleStateManager.GetCurrentAnimatorStateInfo(0).fullPathHash];”

    And that is it!

    In fact you don’t even have to do that, the project will still run fine in Unity 5 as nameHash is still a supported property on the animator at the moment, however I do suggest you update it, just in case in the next update they remove it :S

    If you encounter any other issues in Unity 5 with the title and want to chat Unity 5, just post on this thread.

     

    Simon (Darkside) Jackson
    @SimonDarksideJ

    #7539

    As an update to the Unity 5 support, some people have reported issues with Unity upgrading the Code from the book, thankfully this only affects 2 files.

    If Unity can’t (Won’t) upgrade code, you will see “Unity Upgrading” issues in the console log, these are very easy to resolve as follows:

    • In the FollowCamera script on lines 36/37 replace “camera.ViewportToWorldPoint” with “GetComponent<Camera>().ViewportToWorldPoint
    • In the MapMovement script, replace references to “this.collider2D.enabled” with “this.GetComponent<Collider2D>().enabled

    Apologies for not noticing these sooner, just something that showed up in later 5.x versions.

     

    Happy RPG’ing  😀

    Simon (Darkside) Jackson
    @SimonDarksideJ

    #7972

    The road continues, with each new version of Unity 5, it introduces even more change, with 5.1 we can see there are a few more “improvements” or “Obsolete  Notices” as the busy train keeps moving.

    As I intend to ensure readers always have the latest information, I keep updating this thread, as of 5.1, Unity have put on notice the ability to create simple shaders in code which the book uses as part of the “FadeInOutManager” in chapter x.

    In the chapter we currently have:

    fadeMaterial = new Material(“Shader \”Plane/No zTest\” {” +
    “SubShader { Pass { ” +
    ”    Blend SrcAlpha OneMinusSrcAlpha ” +
    ”    ZWrite Off Cull Off Fog { Mode Off } ” +
    ”    BindChannels {” +
    ”      Bind \”color\”, color }” +
    “} } }”);

    Declaring a shader like this is no longer (or very shortly won’t be) supported, so we have to create the shader in a shader file and then reference to it in code.

    So here are the steps to update:

    1. Create a new folder in the assets project called “Shaders” (we didn’t use shaders specifically in the book, so this is new)
    2. Select the shaders folder and right-click in the project window and select “Create -> Shader“, name it “FadeInOutShader
    3. Open the new shader in your code editor by double clicking on it and replace it’s contents with the following:
      (P.S. if you haven’t already, have you checked out Microsofts new multi-platform lightweight code editor which can be used with Unity? – http://wp.me/p3o0M2-1VH )

      Shader “Custom/FadeInOutShader” { SubShader { Pass { Blend SrcAlpha OneMinusSrcAlpha ZWrite Off Cull Off Fog { Mode Off } BindChannels { Bind “color”, color } } } }

    4. Save the shader and return to Unity and open up the “Scripts\FadeInOutManager.cs” script
    5. Replace lines 26 – 32 (the code shown earlier) with the following

          Shader shader = Shader.Find(“Custom/FadeInOutShader”);        fadeMaterial = new Material(shader);

    6. Save and run.

    All this change does is to move the code generated shader in to an actual shader definition file (removing all the funky stuff we add in the code as well, including escape characters), then we reference that shader in our code and use it for our fading material.  The shader could probably be improved for more effect but that was well outside the scope for the title.

    Any more queries or suggestions, just let me know.

     

     

    Simon (Darkside) Jackson
    @SimonDarksideJ

    #8503

    No changes for Unity 5.2, tested and working fine.

    Simon (Darkside) Jackson
    @SimonDarksideJ

    #8978

    Checked Unity 5.3, it introduces several warnings about the Loading of levels due to the new Multi-Scene Manager improvements. They are only warnings at present and don’t stop anything.
    Will write an upgrade guide soon.

    Simon (Darkside) Jackson
    @SimonDarksideJ

    #10016

    Jason

    Just to let you know, it appears that in 5.3.2 (I haven’t tested in previous 5.x versions) they seem to have fixed the issue you bring up on the Ch 2 “Extra credit”

    #10018

    Jason

    Please scratch the above. It doesn’t stop working, but the x position is always 0.

    #10268

    Leonardo

    Hello Simon DarkGenesis.

     

    reading your book of mastering on Unity 2D with a good RPG, under the chapter 6 and 8(I on there) I see you use the application.loadedLevelName to getting ever the last scene, but it’s obsolete now is using SceneManager.LoadScene(string) to determine what scene have been loaded, but I really trying to make update it to get fixed but I can’t make it yet.

    P.s.: one of this obsolete resource is on MapMoviment.cs of chapter 6 and other on NavigationManager.cs of chapter 8

Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘Mastering Unity 2D Game Development’ is closed to new topics and replies.