Summary of compile and run-time errors that unity beginners can easily commit

Source: Internet
Author: User

When I was teaching Unity Junior, I was often asked by students about some very simple questions about how Unity's error messages were addressed. I would like to know whether these questions can be summed up, to give you a list of the easy error of my workload can be a substantial reduction? Right! Just do it, and here are some of the things I've summed up.


Question 1:

When the script adds the game object process, the error window pops up: "Can ' t add script ..."?
Answer:
The reason is that unity specifies that the file name of the script must be the same as the class name, or error. Please change the name of the unity script or the name of the class.


Question 2:
Run-time error messages encountered during the course of the student's learning Navigation pathfinding: "Setdestination" can only be called on an active agent that has been placed on a NavMesh " ?

Answer:
Typical navigation pathfinding errors are the main reason you need to navigate the game object, place the wrong position, or the Y axis away from the "ground" (NavMesh), or leave the baking "ground." Check the y-axis position of the associated pathfinding lead with the change.



Question 3:
The user to get the project files, there is no open error (no errors). That is, unity does not open the specified unity project in any way?

Answer:
In general, Unity's support for Chinese is not good, so the project path cannot have Chinese. Please check the path of your project file and remove the relevant Chinese path.



Question 4:

When the user imports the *.unitypackage file, an error message appears: "Error while importing PACKAGE:COULDN ' t decompress the package. Failed importing package .....

Answer:
This problem is also generally because unity is not good for Chinese support, so the *.unitypackage file that needs to be imported cannot have Chinese. Please check the path of your "package" (or some *.unitypackage plugin) file, and remove the relevant Chinese path.


Question 5:

Does the user find no sound while running the game engineering process? And the computer hardware is not a problem? The following information is displayed in the console window of unity: "There is 2 audio listeners in the scene"?

Answer:

The reason is that there are more than 2 "Audio listeners" in your current scene, please keep only one, superfluous delete. This usually happens when the learner introduces the "first person/third person" character that unity comes with. You can temporarily disable or delete the audio Listener component of the main camera.



Question 6:

A run-time error message that is most likely to occur during a program's run: "Nullreferenceexception:object reference not set to a instance of an Object"?

Answer:
This is a typical "null reference error", the nature of the original need to instantiate the game object has not been successfully loaded, the instructions behind the program has been used above the object is not instantiated caused by!. Specific questions need to be analyzed to see if any of the components are not loaded, or if the path names of some of the methods such as Getcompont () and resource.load () are correct.



Question 7:
A run-time error message that appears during program run: "Missingreferenceexception:the object of type ' Gameobject ' has been destroyed"
Answer:
Missing Reference Exception! The usual reason is that the specified game object has been destroyed, and the other code has to access (call), causing the error!.



Question 8:
A run-time error message that appears during program run: "Invalidcastexception:cannot cast from Source type to destination type"?
Answer:
Invalid conversion exception: cannot be converted from the source type to the target type. Is it necessary for the learner to carefully examine the program for proper casting? C # "Packing unboxing" is correct and so on.



Question 9:
"Unassignedreferenceexception:the variable golinereddiamend_prefab of ' Scencemanager ' have not been assigned"?
Answer:
The reference exception is not assigned. Usually the public type field in the script, which is not caused by the corresponding "preset" or the game object when the game is running. That is, no parameters are added to the public fields of the script.


Question 10:
The learner is making an error about animation frame animations: "Animationevent has no function name specified"?

Answer:
In animation you define an event without adding a corresponding "event method" to the event, resulting in an error!



The above is my summary of the current 10 common compile-time and run-time errors, please give more valuable advice, and constantly enrich this document so that beginners less detours ", thank you!


This article is from the "Liu in the Clouds" blog, make sure to keep this source http://liuguozhu.blog.51cto.com/9142031/1584768

Summary of compile and run-time errors that unity beginners can easily commit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.