第一回ミニ勉強会 †
ソースコード †
https://github.com/nyarurato/Crage_benkyoukai/tree/master/1/test_project
ダウンロードしてインポートすれば使えるはず
参考資料 †
東京渋谷 unity 勉強会のスライドを参考にしました。
http://tonosamart.com/blog/unity-2011-11-26/
やったこと †
- Unityの基本操作など
- Unityのスクリプトの書き方
- Asset Storeの使い方
具体的内容 †
- Debug.Log
いろいろな確認とかによく使う
Debug.Log("ok");
- GUI
void OnGUI(){
button = GUI.Button (new Rect (0, 0, 100, 30), "onoff");
}
- 当たり判定
- rigidbodyを使っている時
void OnCollisionEnter(Collision other){
//ぶつかってきた物の名前表示
Debug.Log (other.gameObject.name);
}
- Collidarを使っての判定
CollidarのコンポーネントのIs Triggerにチェックを入れる
オブジェクトを透明にすれば、イベント開始などのトリガーとして使えるね
void OnTriggerEnter(Collider other){
if (other.gameObject.tag.Equals("myks")) {
Application.LoadLevel ("gameover");
}
}
- タグ
Inspectorビューで変更可能
gameObject.tag;
スクリプトから取得可能
- prefab
HierarchyビューからProjectビューにドラッグアンドドロップ。
Instantiate (pepo_prefab, gameObject.transform.position, Quaternion.Euler (90, 90, 90));
量産可能
- 入力
project settingsのInput確認
- 前後左右
if (Input.GetButton ("Horizontal")) {
gameObject.transform.position += new Vector3(0,0, keisuu*Input.GetAxis("Horizontal"));
}
if (Input.GetButton ("Vertical")) {
gameObject.transform.position += new Vector3(keisuu*Input.GetAxis("Vertical"),0,0);
}
GetなんちゃらDown-->押した瞬間
Getなんちゃら-->押してる間
GetなんちゃらUP-->離した瞬間
- Destroy
時間指定可能
Destroy(gameObject,10f);
- 複数のカメラ切替
カメラのGameObject?そのものをオンオフする?
- AssetStore?の使い方
AssetStore?を開く、ログイン、ダウンロード、インポート