2017年7月
Instantiate 后 需要重新调整 position,localScale
Frame rate is a standard measure of performance in games. In games, a frame is like a frame in animation; it’s a still image of our game that is drawn to the screen. Drawing a frame to the screen is known as rendering a frame. Frame rate, or how fast the frames are being rendered, is measured in frames per second (FPS).
For every frame that is rendered, Unity must perform lots of different tasks. In simple terms, Unity must update the state of the game, take a snapshot of the game and then draw that snapshot to the screen. Tasks that must occur during each frame include things like reading user input, executing scripts and performing lighting calculations. In addition to this, there are operations which can happen many times during a single frame, such as physics calculations. When all of these tasks are being performed quickly enough, our game will have a consistent and acceptable frame rate. When all of these tasks cannot be performed quickly enough, frames will take too long to render and the frame rate will drop.
Garbage is the term for memory that has been set aside to store data but is no longer in use. Garbage collection is the name of the process that makes that memory available again for reuse.
transform.ChildCount
transform.hierarchyCount
transform.hierarchyCapacity
Vector,Quaternion 都是结构体,通过localRotation,position等以上函数获取的结果都是存在一个结构体中,此时的返回结果是存在单独开辟的新内存中,因此对其直接修改不能影响其原有数值,我们必须以localRotation = Vector这种形式对其赋值,让其进行函数内进行实际赋值操作
lhs(left-hand size)指的是==运算符左边的操作数
rhs(right-hand size)指的是==运算符右边的操作数
gizmos 2d模式 不能改变大小 3d模式 可以改变大小
if a gameobject has no parent its transform properties measured in world space
when a game object is active all over the enabled components on the game object will be processed when the game is running
when dragging a game object if the selected game object contains a component that matches the reference property type unity will assign the appropriate component to the matching reference
if a matching component type cannot be found on the game object it will be rejected
可以同时打开多个inspector窗口
if the scene list is empty unity will build an executable but it will only use the existing open scene
the order of scenes in this list have an impact on the game when it's running the scenes will be indexed in the order that they appear in the list unity will open and play the topmost scene in the scenes in build list first other scenes will be loaded by name or by index number
unity editor is editor itself
everything in video games is based off a coordinate system?
ContextMenuItem
MenuItem
Perlin noise
https://en.wikipedia.org/wiki/Perlin_noise
Mathf.PerlinNoise
Mathf.MoveTowards
This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta
. Negative values of maxDelta
pushes the value away from target
.
LookAt can be used to make a gameobject's forward direction point at another transform in the world
Generic<T,U,V>
in unity a transforms rotation is stored as a quaternion
one of the most important thing is to remember about dealing with quaternions is that since the x y z and w components work together you should never adjust them individually
Global illumination, or ‘GI’, is a term used to describe a range of techniques and mathematical models which attempt to simulate the complex behaviour of light as it bounces and interacts with the world. Simulating global illumination accurately is challenging and can be computationally expensive. Because of this, games use a range of approaches to handle these calculations beforehand, rather than during gameplay.
By default, lights in Unity - directional, spot and point, are realtime. This means that they contribute direct light to the scene and update every frame. As lights and GameObjects are moved within the scene, lighting will be updated immediately. This can be observed in both the scene and game views.
Collider[Collision Message] && Trigger Collider[Trigger Message]
按住ctrl的同时点击collider的顶点可以删除这个顶点
AreaEffector2D PointerEffector2D SurfaceEffector2D PlatformEffector2D
In 2d mode there is no ability to rotate the scene view camera so in 2D mode the scene gizmo is hidden.
Pixels to units defines the number of pixels from the sprite that will correspond to 1 unit in world space
Sorting layers work with the sprite renderer to determine the redering order of sprites regardless of their distance from the camera.
For even more control,individual sprites can be assigned an Order In Layer value to define the rendering order of sprites within a sorting layer.
All objects added to the scene will receive ambient light unless the ambient intensity value is set to 0 or the ambient light's colour values are set to black
By default all objects in the scene will also receive reflection information.
Even though the cube,sphere and plane in the scene are unlit and ambient light is none they still receive lighting information in the form of reflections.
The default reflection source is the sky box.
This can be changed to a custom cube map.
To receive no default reflections either set the custom cube map to none,or remove the sky box.
Linear colour space && Gamma space
A rect transform can be anchored to it's parent if that parent also has a rect transform component.
The pivot point is indicated by a blue ring which by default starts in the centre of the UI element.
User input is usually the pointer hovering over or clicking on the button graphic.
When a scene starts,the event system looks for input modules,and uses those to define how each UI element should react to input.
The transition property defines how a UI element behaves in each state and how it behaves when changing states.
The scroll rect is a UI element that allows the user to move another UI element along the horizontal and/or vertical axes.
Objects must be between the near and far clipping planes to be rendered.
A skybox is a material that contains several images that surround the entire scene providing a textured background for that scene.
The content of what the camera is rendering is limited by the Culling Mask property. The Culling Mask drop down will list all the layers available in the scene.The camera will render only those objects on the layers selected in it's culling mask.
The order that scripts are on a game object is linear
The deltaPosition property is a vector2 that is the difference between the touch position last frame to it's position this frame
By default unity does not optimise model rigging.
What that means is that unity will create many empty game objects to represent all of the model's bones and joints.
This gives you access to the transforms of all of the model's parts,but it is much less efficient.
In most cases you will not need this level of control.
Therefore it is recommended to check optimise game objects.
By checking "Optimize Game Objects" box unity will not create extra empty game objects.
Obviously not managing all of those transforms will improve the performance of your game.
"Extra Transforms to Expose"
However under some circumstances we might want to reference a particular part of a model in code or in the Hierarchy.
Mapping
Circles represent the bones of the model.
Ones that are circled with a dotted line are optional and are not necessary for the definition.
Mapping drop-down menus.
Clear Clear will remove all of the bone allocations
Automap will get unity to try and fit the correct transforms to their bones.Generally this is the best approach to start with when configuring an avatar.
Load and Save are for dealing with humanoid templates so you can use configurations across multiple avatars.
These are generally not required as unity will usually be able to automap your avatar.
The pose drop-down menus.
Reset removes any pose from the avatar and sets it to it's default.
Sample Bind-Pose tries to set the avatar to the pose in which it was modelled.
Enforce T-Pose sets the avatar in to a T pose. This is the way that Unity prefers to deal with avatars. When you hava finished mapping it is best to set the avatar in to a T pose.
Transform.TransformPoint Transforms the position x
, y
, z
from local space to world space.
Transform.InverseTransfromPoint Transforms position
from world space to local space.
RectTransform.position == Transform.position
Rigidbodies are components that allow a game object to be effected by physics.
The is kinematic setting effects whether or not a rigid body will react to physics.
Ordinarily when a scene begins, all static geometry,meaning any non-rigidbody objects are checked once by the physics engine and not checked again for efficiency.
However when you move a static object the physics engine must re-check all other static objects for the sake of accuracy,and this can be expensive to performance.
To avoid this,kinematic rigidbody objects can be used and moved via their transform by using the Translate function.
The AddForce function is a function that is used to start a physics object moving,or to change the speed or direction of it's movement.
AddForce can also be used in FixedUpdate to apply a constant force.
ForceMode.Force This is used for continuous changes that are effected by mass.
ForceMode.Acceleration is for continuous changes that aren't effected by mass.
ForceMode.Impulse is for an instant change that is effected by mass.
ForceMode.VelocityChange is for an instant change that is not effected by mass.
You should also keep in mind that forces are dampened by the rigidbody's drag property,for example,if drag is increased,then the force applied will be less effective.
And naturally on the opposing side if the amount of force is increased then the force will be more effective.
The AddTorque function is similar to AddForce,but the force works by rotating the game object around a defined axis.
Dynamic Friction is how much friction exists whilst the object is moving and Static Friction is how much force is required in order to move the object from a static position.
Raycasting is the process of shooting an invisible ray from a point in a specified direction to detect whether any colliders lay in the path of the Ray.
The origin of the ray is a point in world space
Raycast hit variable that stores information on the colliders hit so that it can be queried in as to which objects are intersected by the Ray
Distance which defines the length of the ray if omitted the Ray will default to an infinite length
LayerMask this is the number of a particular layer in unity layer system on which you can place objects if you wish to make the ray ignore them
Debug.DrawRay Only SceneView
Animator controllers are unity generated assets that contain one or more state machines which determine which animation is being played while the scene is running.
The avatar is an asset that unity creates when importing a 3D humanoid.It contains a definition of the skeletal rig the character has.
The Apply Root Motion field determines whether the animation can affect the transform of the game object and is generally used with 3D humanoids.
Root Motion is the core movement within an animation clip.
The culling mode of an animator effects whether or not the animations are being played while they're not being rendered.
Always Animate means that the animations will play even while not being rendered.
Based On Renderers means that the animation will only play while being rendered.
The default state is the one who's animation will be played to start with.
Foot IK,If this option is checked it will reduce or eliminate any foot slipping in your animation.
Mute effectively disables the transition
Solo takes into account all the transitions that come from the same state and effectively mutes all those that aren't marked as solo.
Mute and solo are tools for debugging and focusing on particular areas of state machines.They should not be checked on any published builds.
If the atomic property is checked it means that the transition is not interruptible by other transitions.
Between the start and end marker is a blue shaded region which represents the transition from one animation to the next.
IK Pass,When a layer does an IK pass it means that onAnimatorIK function will be called for that layer with the appropriate layer index.
The Weight represents how much the layer effects the final animation.A weight of 0 means the layer will not effect animation at all.Inversely a weight of 1 will completely change the animation.Layers of higher weights have priority over lower ones.
The Mask property of a layer defines which,if any,avatar mask the layer will use to isolate body parts for animation.
If the blending mode is override then the result animation will override the animation of the lower layer as defined by the weight.
Additive blending will result in the animations on the additive layer being added to or combined with the animations of lower layers.
Where you check the Sync box you are given an option of which layer you wish to sync with.
This will create an identical state machine to the one on the selected layer but with no motions.
This means that the animator will always be in the same state in both layers.
The Timing checkbox allows the animator to adjust how long each animation in synced layers takes determined by the weight.
The mesh filter holds the mesh data of the model and passes it to mesh renderer for rendering on screen.
The mesh renderer takes the mesh model data from the mesh filter and renders it in our scene at the position,rotation and scale defined by the object's transform component.
1 public void Save(){ 2 BinaryFormatter bf = new BinaryFormatter(); 3 FileStream file = File.Create(Application.persistentDataPath + "/playerInfo.dat"); 4 5 PlayerData data = new PlayerData(); 6 data.health = health; 7 data.experience = experience; 8 9 bf.Serialize(file,data); 10 file.Close(); 11 } 12 13 public void Load(){ 14 if(File.Exists(Application.persistentDataPath + "/playerInfo.dat")){ 15 BinaryFormatter bf = new BinaryFormatter(); 16 FileStream file = File.Open(Application.persistentDataPath + "/playerInfo.dat",FileMode.Open); 17 PlayerData data = (PlayerData)bf.Deserialize(file); 18 file.Close(); 19 20 health = data.health; 21 experience = data.experience; 22 } 23 } 24 25 [Serializable] 26 class PlayerData{ 27 public float health; 28 public float experience; 29 }
Tiled2Unity 不能重名