- Home /
Unity 5 API Updater Keeps Failing
I've run into a pretty big problem with Unity 5's API changes.
After upgrading, I was presented with 156 errors from deprecated properties. Every time I tried to run the API updater, it failed and told me to check previous console messages. All the previous messages ever stated was that certain errors were preventing the updater from working, but gave no further information. After fixing some errors, the updater was still failing but was no longer giving any "previous" messages.
I ended up just fixing all 156 errors myself. However, I must be using a colossal amount of these deprecated properties in my project, because after fixing the last of the 156 errors, I was then presented with 537 more.
The updater is still failing, and there are still no previous console messages.
Okay, I really don't want to manually fix 537 errors if I don't have to, especially if there might be even more revealed afterwards. All of the errors are "UnityUpgradable", yet the updater hasn't been able to fix a single one. So far with Unity 5, the API updater has been completely useless, as I've had to fix every single one of these errors myself.
Does anyone know what might be causing this? Is there anything I could possibly check?
I'm sorry I can't provide any more information. I can only provide as much as Unity gives me, and so far it hasn't really given me anything.
Bump
I'm not sure whether or not this would be worthy of a bug report. I thought I'd check here first to see if anyone knew anything before I thought about sending one. Again, even if I fixed all these errors (about 460 now) manually, I'm afraid even more will show up. I'd prefer to just use the updater for all of these, as that's what it's for and as I stated above, all errors are UnityUpgradable.
[$$anonymous$$ETA] Seeing as you went to the effort of writing a paragraph you may as well have not included the word 'bump'. Bumping threads is kinda frowned upon here so you could have achieved it without looking like it. Just a Pro tip to make people not hate you ;)
Other script API changes that cannot be upgraded automatically
UnityEngine.AnimationEvent is now a struct. Comparisons to ‘null’ will
result in compile errors.
AddComponent(string), when called with a variable cannot be
automatically updated to the generic version AddComponent(). In such cases the API Updater will replace the call with a call to APIUpdaterRuntimeServices.AddComponent(). This method is meant to allow you to test your game in editor mode (they do a best effort to try to resolve the type at runtime) but it is not meant to be used in production, so it is an error to build a game with calls to such method). On platforms that support Type.GetType(string) you can try to use GetComponent(Type.GetType(typeName)) as a workaround.
AssetBundle.Load, AssetBundle.LoadAsync and
AssetBundle.LoadAll have been deprecated. Use AssetBundle.LoadAsset, AssetBundle.LoadAssetAsync and AssetBundle.LoadAllAssets ins$$anonymous$$d. Script updater cannot update them as the loading behaviors have changed a little. In 5.0 all the loading APIs will not load components any more, please use the new loading APIs to load the game object first, then look up the component on the object.
There are a few things that will cause the Updater to fail. At the moment that information seems to be scattered far and wide.
I suppose using the term "bump" when bumping is a habit of $$anonymous$$e. $$anonymous$$oreover, I've seen countless "bumps" on UA and not once was the person "hated" for it. I also don't really see an issue with it seeing as perfectly valid unanswered questions end up 4 pages down within a single day and never get the chance to be seen by someone who might be able to help.
Anyway, thanks for the information. It's discouraging but I suppose nothing can be done about it. I only figured since the errors say "UnityUpgradable" and the $$anonymous$$m at Unity has stated that the ones which say "UnityUpgradable" are the ones the updater can fix, I would be able to rely on it for that.
EDIT: So far all of the errors have been due to the use of "audio.", "animation.", "camera." and "renderer.". All I've had to do to fix these is simply use "GetComponent()" ins$$anonymous$$d. This is actually shown in the release notes as an example of something the updater should be fixing. That's why I've come to believe something is wrong. I'll just need to add "GetComponent()" at least 460 more times, which seems a little silly to me.
Ok, hated was a strong term, I used it in jest :P
The best way to bump is to simply add more information.
I think the information on GetComponent is misleading. You can still cache things the old way, using GetComponent only once. The example was for a rigidbody which I believe was simply demonstrating that you shouldn't rely on the 'rigidbody' alias anymore. Do the GCmpnt-Rigidbody step in Start() and call the variable rb not rigidbody (calling it rigidbody gives an error about overriding or something, dont remember).
If you really want to go ahead and change them all, use something Like Replace All In Files with NotePad++.
Answer by tanoshimi · Mar 06, 2015 at 10:46 PM
You shouldn't need to change each reference individually. Just define:
private AudioSource audio;
private Camera camera;
etc.
void Awake () {
audio = GetComponent<AudioSource>();
camera = GetComponent<Camera>();
etc.
}
Once at the top of each of your scripts. All previous references to audio.Something() and camera.Whatever() in the rest of the code should then not need any additional changes - they'll just access the cached references declared here.
Note that there is an error thrown if the variable name you choose matches that of a previous alias.
Notice the Upgrade Info example uses 'rb' for rigidbody variable name now, ins$$anonymous$$d of 'rigidbody'.
Thank you both for the suggestion, but wouldn't this be just as much, if not more tedious work than what I've already been doing? There are a lot of scripts I would need to make these changes to, and creating and defining variables in each one of them would take even longer than just replacing all the obsolete references with GetComponent()'s via $$anonymous$$onoDevelop's find/replace feature.
If it works and doesn't slow down your game, go for it.
You want Find/Replace 'In Files' to get them all in one go. Not sure if $$anonymous$$ono does that. I don't really use it.
Answer by Truvak · Apr 07, 2015 at 01:01 AM
Hi, I am very new with Unity and maybe this is not the place for this question but please help me.
I´ve watched 50+ hours of videos about Unity, the 3 beginners tutorials, all the scripting, UI, and 2D topics and some Yt videos with more tutorials, all before even touching the program in order to learn first and practice later.
Now I am trying the Project: Roll-a-Ball and on the very first script the program tells me:
Some scripts have compilation errors which may prevent obsolete API usages to get updated. Obsolete API updating will continue automatically after these errors get fixed.
This is the code that Unity corrected for me:
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
GetComponent<Rigidbody>().AddForce (Vector3);
}
}
The line on GetComponent was changed as you can see from the script on the video 03.Moving the player, I can see that there are some changes, all the videos are for 4.6, can you please tell me what to do? I really, really want to learn Unity, but this is very confusing to me.
Thanks:
David
$$anonymous$$, you have: GetComponent().AddForce (Vector3); you need: GetComponent().AddForce (movement );
You created a Vector3 named movement, and that is what should be passed into the Addforce function
Answer by First-47777-Guy · Aug 14, 2015 at 12:06 PM
getcomponent() that's the thing that links the rigidbody component to the script. your building a character controller just by looking at that. it seems everything is unable to update there api with the api updater, it seems like a big problem that unity needs to fix as soon as possible. iv'e experienced the problem more than once and i tried fixing the errors and every time i it got more problems. it looks like the problem is that you can't fix it, that's why the api updater fails. it might have something to do with unity and how all of the scripts are ment to be able to work with il. here is the most recent script problem i have
if(Input.GetKeyUp(KeyCode.KeypadEnter)&&!Climbing){
the hole script
pragma strict
/do we want the character to climb or not var Climbing:boolean; //the speed we want the character to travel at public var speed:float = 5.0; //the character who is climbing this ladder public var target : Transform;
function OnTriggerStay(other:Collider){ //gets the person who touches the ladder //if the personhits enter start the climbing //if we are climbing stop climbing if(Input.GetKeyUp(KeyCode.KeypadEnter)&&!Climbing){ target=other.transform; Climbing=true; return; // any code you need to turn back on control of your playercontroller gos here // this by default is setup for the character motor // its turn the control,gravity and the stepoffset on }else if(Input.GetKeyUp(KeyCode.KeypadEnter)&&Climbing){ Climbing=false; target.GetComponent(CharacterMotor).canControl=true; target.GetComponent(CharacterMotor).movement.gravity=20; target.GetComponent(CharacterController).stepOffset=0.4; target=null; } // any code you need to turn off control of your playercontroller gos here // this by default is setup for the character motor // its turn the control,gravity and the stepoffset off if(Climbing){ target.GetComponent(CharacterMotor).canControl=false; target.GetComponent(CharacterMotor).movement.gravity=0; target.GetComponent(CharacterController).stepOffset=0; //locks the players x,z axis to the ladders since we only need to move on the y axis target.position.x=transform.position.x; target.position.z=transform.position.z; //this allows the player to move up and down the ladder if(Input.GetKey(KeyCode.UpArrow)){ target.Translate(Vector3.up Time.deltaTime*speed); }else if(Input.GetKey(KeyCode.DownArrow)){ target.Translate(Vector3.down Time.deltaTime*speed, Space.World); } } }
// any code you need to turn back on control of your playercontroller should go here // this by default is setup for the character motor // it turn the control,gravity and the stepoffset on // also pushes the character forward so in case the character is on top of the ladder function OnTriggerExit(other:Collider){ if(target){
target.GetComponent(CharacterMotor).canControl=true; target.GetComponent(CharacterMotor).movement.gravity=20; target.GetComponent(CharacterController).stepOffset=0.4; target.Translate(Vector3.forward * Time.deltaTime*20); Climbing=false; target=null; } }
STOPPER
pragma strict
/the person on the ladder private var target:Transform;
function OnTriggerStay(other:Collider) { //the person this touching is on the ladder //if the person hits the down key this moves them up counteracting the ladder moving them down target=other.transform; if(Input.GetKey(KeyCode.DownArrow)){ target.Translate(Vector3.up * Time.deltaTime*5, Space.World); } }
function OnTriggerEnter(other:Collider) { //the person this touching is on the ladder //if the person hits the down key this moves them up counteracting the ladder moving them down target=other.transform; if(Input.GetKey(KeyCode.DownArrow)){ target.Translate(Vector3.up * Time.deltaTime*5, Space.World); } }
//gets rid of the target if they are not touching the ladder function OnTriggerExit(other:Collider) { target=null; }
this is the error message
Assets/project assets/scripts/LadderClimbing.js(16,41): BCE0044: unexpected char: 0xAD.