1.drag sprites to a gameobject will create animation and animator automatically with those sprites.
2.in box collider2d, make size a little smaller so won’t collide thing in other tile
3.3d physics and 2d physicsc can exist together in one scene, but won’t interact
4.hold shift to change the collider box in collider 2d
5.sprite is a texture, it need to be set in texture type,2d project will set texture to sprite automatically. Multiple mode can mean it contain animation sheet or separate part of a unit. Pixel to unit: how many pixel calculated
6.inspector can be locked.. So when you add prefabs into a list, can select multiple and drag into the list
7.instance:
In GameManager:
public static GameManager instance = null;
In GameManager.awake:
if (instance == null) {
instance = this;
} else if (instance != this) {
Destroy (gameObject);
}
In Loader:
if (GameManager.instance == null) {
Instantiate (gameManager);
}
Then we only need Loader script in game
8.in animation transition, settings, can set transition duration as 0 since for 2d sprite there is no way to blend.
Set exit time to 1 so to transite when the animation is end
9.[HideInInspector] for public variable that can’t be seen in editor
10.The Serializable attribute lets you embed a class with sub properties in the inspector. The class should be serializable:
[Serializable]
public class Count
{
public int minimum;
public int maximum;
public Count (int min, int max)
{
minimum = min;
maximum = max;
}
}
Now when you wirte public Count enemyNumber; this number will be shown in inspector
11.when inherite, the parent method should be protected virtual or protected abstract, and the child method should be protected override .
12.template:
protected abstract void OnCantMove<T> (T component)
where T:Component{}
When override, no need to say the T:
protected override void OnCantMove<T>(T component){ }
When use:
OnCantMove<Wall> (Wall wall);
13.if raycast, it might: collide with it self, can uncheck
Edit -> Project Settings -> Physcis 2D -> Raycasts Start In Colliders to avoid this.
14.Linecast, will do ray cast in a segment
15.new way to load new level:
SceneManager.LoadScene(0);
Also import:
using UnityEngine.SceneManagement;
16…. A good structure is very important. I should try to write my own game to practice this skill
17.test animation in animator controller to make sure the transition works.
18.called when a level is loaded :
void OnLevelWasLoaded(int index){
19.can drag same kind of component to different variable.
20.method(param Gameobject[] object) can parse any number objects and will treat them as an array. Just skip the step to create an array yourself.
Use: method(object1,object2..)
21.-Vector2.one = out of screen
23.when import assets from assets store, pay attention that your settings and layers and everything might be changed.. Which will cause a lot trouble…