Unity3d game development MonoDevelop garbled problem

Source: Internet
Author: User

Unity comes with the MonoDevelop project view on my Computer (Win7) has been garbled, project name, Project tree, and file name all display Solutionkeys box, today, the font changed, the default font to Consolas, the unintentional insertion willow solved the problem ...



In addition to look for a long while not to see the Change Code Editor font options, do not know where to change the editor font? Please tell me which one of the students you know.

Some concepts and syntax about unity

Recently has been in the use of free time to see the Unity API, look at the relatively thin but the actual operation of the relatively few, yesterday there is a full day of free time, plus have a good idea, want to realize it, because the model used is not complex, do not need to use the modeling software, do not go around to engage in material, The stickers are easily filtered and cut from the collected pictures, and everything looks easy to get done, so start writing code. I started writing from the basic GUI, the landing box, the main menu, which is the basic way to enter the game, and then new game into the first level, where the show is just beginning.


I spent a lot of time picking up stickers and experimenting with different shader, which is not the point, when I wrote the user input character detection, I was dumbfounded, I found some code on unity answer, Loaded system.regularexpression ( Loading part of the extra code, and I want to try to keep the size of the game as small as possible, and then use regular expressions to do replace, there are relatively simple character comparisons, with Event.current.character characters ' a ', ' Z ', ' a ', ' z ', ' 0 ', ' 9 ' To compare, this is the code in C #, in the unityscript will be prompted not to convert the string type to char type, this problem is more involved. Since Unityscript does not automatically convert a string to char, will I have to convert it manually? But the basic types of methods in Unity's documentation


Basically not mentioned, then how does unity deal with these basic types of string,char,array?



Here are some key concepts to clarify. Unity provides three scripts for us to use, and C#,JS and boo,javascript programmers may find it handy to use JS, but don't be fooled by appearances. This JS and we are familiar with the ECMA version of JS has a big difference, which is why I am inclined to call it untyscript rather than JavaScript, it does not have the type of JS declaration, no object direct volume and function direct amount, no prototype inheritance mechanism, But more classes, unions, extent inheritance and so on. Unityscript is implemented by the Boo language, Boo runs on the mono virtual machine, translates the cost to code execution, and Mono is an open-source. NET Framework. The basic type of unityscript used, such as Char,string,array, is to directly check mono's documentation.


The above-mentioned users of the famous university test problem is actually a method of char isletterordigit can be easily solved, but if not to see Mono's document I certainly do not know this.


Speaking of the difference between Unityscript and JavaScript, in fact, the official wiki has a more detailed post, I also use these things, one into the complex code details, only to find these problems, of course, some things are usually also natural use, such as Var s:int; This way of writing, in JS is Var s; it is necessary to avoid the overhead of type detection with strongly typed declarations. There are also some areas to be aware of:

  • In JS, before the variable declaration of Var can be omitted in some cases, but in unity if the declaration of a variable is not Var, the scope of the variable is global.
  • There is no prototype inheritance mechanism, inherited syntax: Class Foo extents Bar {};
  • You can define a virtual function, which can be overridden by a class, and the syntax is virtual function do () {something;}, the virtual keyword is added to both the parent and child classes
  • In subclasses, use the Super keyword, such as class Foo extents bar{virtual function do () {super, to tune the parent class's method. Do (); /*...more code. */ }; }
  • A simpler approach than inheritance is to get the parent class component name directly, using its method, using unity-provided function getcomponent (), plus a little trick, if you use static to declare a variable in a script, Use the script name directly in other scripts. variable is accessible without getcomponent ()
  • String uses the subscript operation to get the char type, such as "Foobar" [3] to get char type character ' B '
  • Unityscript Each script is a class that inherits from Monobehaviour, which needs to be explicitly declared in C # and Boo, but is implicitly and automatically done in Unityscript, each script name is a class name, which is a type name, A variable declared in the global context of a script is actually a property declared as the script class, and the global function is actually its method, and in this class you can define other classes as well.
  • There are two kinds of arrays in Unityscript, basic array and JavaScript-like array, array direct volume such as [1, 2, 3] is the array type, can only use subscript operation, cannot use push such method, to declare an array must use var a = New Array (), it is recommended to replace it with a List of. NET, declaring a method that is a little different from C #: var myList = new list. (); Note the middle dot symbol
  • Unityscript using enumerations: Enum Someenum {AAA, BBB, CCC, DDD};
  • Because the Unityscript is running on mono, you can use the Mono library, using the import System; Import System.IO (File operations in unity, you can use this, such as System.IO.File.Open () to open a file)
  • Because Unityscript is running on mono, you can use a third-party library, such as Xml-rpc.net, to introduce its. dll file with the Import keyword
    Please click " Dog planing Learning net " for more highlights.


On the multiplication of rotation and quaternion in unity

Hand-written game after a more personal experience, is the actual operation can test a lot of language details, perhaps usually look at the API document, or see some tutorials when there is no profound experience, because most of the time you only know how to do, but do not know why to do so, or how to think of doing so, Is there any other approach? In the project I want to use a camera around the script, I found that the official asset already have such a script, open to see its code is very simple, just more than 10 lines, where the more critical line of code, with the camera's rotation control camera position, this method is very ingenious:

    1. Position = Rotation*vector3 (0.0, 0.0,-distance) + target.position;
Copy Code



There are two types of unity-defined quaternion multiplication overloads:

    1. Static operator* (Lhs:quaternion, rhs:quaternion): quaternion
    2. Static operator* (Rotation:quaternion, Point:vector3): Vector3
Copy Code



The two overloads are very different, the first is to calculate the rotation of an object after the LHS and then rotate RHS, the entire result is actually equivalent to how much rotation, the parameters and the return value is quaternion, that is, the rotation angle, and the second is to calculate a Cartesian coordinate system a point, After the rotation rotation, it appears in that position, and the return value is Vector3.

Here target is the object that the camera is going to surround, the distance is the distance to keep it, and the camera's position is the point to calculate. Last night I have been thinking, why this formula is set up, check the quaternion * Number of overloaded to see the fame, before looking at the API document I have seen this, but did not think it can also have such a magical. We know the angle of rotation of the camera, around an object, can only be left and right and up and down the direction of rotation, along the depth of the rotation is not much meaning (perhaps you will think the player will also like upside-down angle, but in my project does not need), So rotation.eulerangles must be in the form of (x, y, 0), before I wonder why the point being rotated is on the z-axis, not on the x-axis, and if it's on the x-axis, then the rotation point is Vector3 (-distance, 0, 0), The direction of rotation must be along the y-axis and z-axis, which is contradictory to the rotation only on the x and Y axes.


Another question that is not thought out or that is not seriously thought about is how the rotation angle is calculated. I have always thought that rotation is the angle of rotation relative to the axis, such as the camera around the script, the X-value of the rotation is relative to the x-axis rotation angle, but when the rotating object moves to the x-axis of the world coordinate system, The value of rotatiion should appear to be 0. This inference obviously rotation is calculated relative to its own coordinate system, but in the local coordinate system it seems that the three values of x, Y, Z should be 0 unchanged, because the local coordinate system rotates with the rotation of the object. For more highlights, click on the "Dog Planing Learning net】


In fact, as long as the unity of the rotation rotation of the calculation method, the above problems are solved:


The type of rotation in unity is quaternion, which can be converted to a VECTOR3 representation using the Eulerangles attribute, which we can use as a vector, where the vector is calculated based on the vector position of the starting and ending points, But all vectors have a value computed from the origin of the coordinate system, which is the credential of its position, which is absolute in the world coordinate system, and the former is relative, and the two actually have some kind of unity. Referring to this calculation method, the rotation of the three coordinate values can be explained. Unity compares the world coordinate system with the local coordinate system, calculates the absolute rotation angle based on the deflection of the local coordinate system relative to the world coordinate system, calculates the relative rotation angle based on the absolute angle of the coordinate system before the rotation rotation and the absolute angle of the coordinate system after it is applied. So where is the origin of the rotation? In the Properties panel, the rotation property of the object can be seen in 0, the origin of the rotation state is the local coordinate system and the world coordinate system x, Y, z three axes in a consistent state.


Unity3d game development MonoDevelop garbled problem

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.