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. Dismiss Notice

Unity 5 API issues!!?

Discussion in 'Scripting' started by rmele09, Mar 6, 2015.

  1. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    688
    So I am pretty confused about the API changes. I have scripts that are broken now, and I don't understand how to fix them. For example, the API script updater changes all my AddMixingTransform code. So I am getting a GefRef error that is non specific AKA does not tell me what line it is on. I check the scripting reference, and the it is still showing all of the old javascript syntax that I am used to....So how on earth am I supposed to learn the new syntax if the scripting reference is not updated and the automatic API updater thing is not working correctly! What am I missing here??
     
  2. Anozireth

    Anozireth

    Joined:
    Feb 7, 2013
    Posts:
    71
    Can you post an example of the code with the problem and what the compiler error says?
     
  3. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    688
    If I keep my old syntax, it is giving me 25 errors of:

    BCE0048: Type 'UnityEngine.Component' does not support slicing.
    Which I am guessing are variable errors?
     
    Last edited: Mar 6, 2015
  4. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    688
    When I use the syntax that the API updater replaces, I get one error that does not point to a line that reads:
    NullReferenceException: GetRef

    New API Code:
     
    Last edited: Mar 6, 2015
  5. Anozireth

    Anozireth

    Joined:
    Feb 7, 2013
    Posts:
    71
  6. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    688
    I read that link and I am still pretty confused. Are those just a few random examples of the API changes? Thanks for your help by the way.
     
  7. Anozireth

    Anozireth

    Joined:
    Feb 7, 2013
    Posts:
    71
    Yeah, I haven't seen an exhaustive list of the changes. Maybe in the 5.0 release notes?
     
  8. Anozireth

    Anozireth

    Joined:
    Feb 7, 2013
    Posts:
    71
    SCRIPTING
    Note: Many scripting changes should be handled automatically by our new API upgrade tool, seehttp://blogs.unity3d.com/2014/06/23/unity5-api-changes-automatic-script-updating/

    • AddComponent(string) is removed. Use AddComponent() instead.
    • Added generic version of Object.Instantiate (has been in the docs since 3.5 but not exposed in the API before).
    • Application.RegisterLogCallback() and RegisterLogCallbackThreaded() have been deprecated and replaced by two new events Application.logMessageReceived and Application.logMessageReceivedThreaded. This allows for multiple subscribers.
    • C# compiler defaults script encoding to UTF8.
    • Deprecated Component.active property has been removed.
    • GameObject.SampleAnimation() moved to AnimationClip.SampleObject().
    • 'Metro' keyword was replaced to 'WSA' in most APIs, for ex., BuildTarget.MetroPlayer became BuildTarget.WSAPlayer, PlayerSettings.Metro became PlayerSettings.WSA. Defines in scripts like UNITY_METRO, UNITY_METRO_8_0, UNITY_METRO_8_1 are still there, but along them there are defines UNITY_WSA, UNITY_WSA_8_0, UNITY_WSA_8_1.
    • ParticleSystem.safeCollisionEventSize changed to ParticleSystem.GetSafeCollisionEventSize().
    • Removed quick property accessors, like .rigidBody, .rigidbody2D, .camera, .light, .animation, .constantForce, .renderer, .audio, .networkView, .guiTexture, .collider, .collider2D, .particleSystem, .particleEmitter, .guiText, .hingeJoint for modularization. Instead, use GetComponent to get references.
    • Removed obsolete graphics APIs: Camera.mainCamera (use Camera.main), Camera.GetScreenWidth (use Screen.width), Camera.GetScreenHeight (use Screen.height), Camera.DoClear, Camera.isOrthoGraphic (use Camera.orthographic), Camera.orthoGraphicSize (use Camera.orthographicSize), Renderer.Render, Graphics.SetupVertexLights, obsolete Graphics.DrawMesh overloads (use DrawMeshNow), RenderTexture.SetBorderColor, Screen.GetResolution (use currentResolution), Mesh.uv1 (use uv2 instead), SkinnedMeshRenderer.skinNormals, LightmapData.lightmap (use lightmapFar instead).
    • Removed SystemInfo properties deviceName, deviceVendor, deviceVersion and supportsVertexProgram. Use graphicsDeviceName, graphicsDeviceVendor, graphicsDeviceVersion instead. Vertex programs are always supported.
    • TerrainData.physicMaterial changed to TerrainData.GetPhysicMaterial() and TerrainData.SetPhysicMaterial().
     
  9. Anozireth

    Anozireth

    Joined:
    Feb 7, 2013
    Posts:
    71
    I'm still not sure why your code doesn't work though.
     
  10. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    688
    Thanks for posting it. I'll figure it out, probably an old error and now its called something different I'll mess with it.
     
  11. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    688
    Thats a great list very helpful.
     
  12. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    JavaScript does generics differently to C#.

    I believe you are looking for

    GetComponent(Animation)["..."].
     
  13. Jarvan5026

    Jarvan5026

    Joined:
    May 22, 2015
    Posts:
    1
    Thx a lot! I'm looking for the solution for quite a long time!