Date post: | 18-Dec-2014 |
Category: |
Technology |
Upload: | shinsuke-sugita |
View: | 20,123 times |
Download: | 2 times |
Unity Programming on Boo
2011/11/5(土)
@shinriyo出版社: アスキー・メディアワークス (2011/6/23)
Booとは?
Pythonもどき
静的型付けのオブジェクト指向言語
強力なメタプログラミング言語
設計&開発者 Rodrigo B. De Oliveira
ロドリーゴ・ビー・ド・オリヴィアhttps://github.com/bambooブラジル出身?Unity勤務?
特徴インデントが文法な上、短い
import UnityEngine
class GameZombie (MonoBehaviour): public SomeWhiteTexture as Texture private hot as bool = true private cameraFlg as bool = true private isOver as bool = false def ApplyDamage (damage as int): Destroy(self)
def Start (): animation.Play("Zombie Walk");
https://market.android.com/details?id=com.shinriyo.tsuminbie
文末に「;」 がいらない
クラスは必要Input.ResetInputAxes()
def Update ():
: が必要
リスト内包表記(list comprehensions)もOKimport UnityEngine
class NewBehaviourScript (MonoBehaviour): doubles as List
def Start (): doubles = [i*2 for i in range(5)]
def Update (): for dbl in doubles: Debug.Log(dbl)
02468
結果
直接Vector3の値へ代入OK
var aPosition : Vector3;aPosition.x = 1;
aPosition as Vector3aPosition.x = 1
US
Boo
注意点
def HogeMethod (hoge as single):
Debug.Log (hoge )
float ではなくて single型
アイコンがへん
.booです
.pyではない
Unity Script(以下US)では必須コンポーネントの記載は@だったが
カッコ []
[RequireComponent(CharacterController)]
@script RequireComponent(CharacterController)
Boo
US
コルーチンの注意function Do () { print("Do now"); yield WaitForSeconds (2); print("Do 2 seconds later");}
IEnumerator Do() { print("Do now"); yield return new WaitForSeconds(2); print("Do 2 seconds later"); }
def Do() as IEnumerator: print('Do now') yield WaitForSeconds(2) print('Do 2 seconds later')
US
C#
Boo
publicは明示的に記載
var walkSpeed = 2.0;
public walkSpeed = 2.0
US
Boo
C#と同様クラスは必須
クラスは必要class ThirdPersonController(MonoBehaviour):
USには不要だが・・
if文とか
クラスは必要if IsGrounded():
elif IsGrounded():
else ifじゃない
コメントの書き方
クラスは必要
# ANIMATION sector// Set rotation to the move direction/* do something*/
''' Apply gravity- extra power jump modifies gravity- controlledDescent mode modifies gravity'''
空メソッドの注意
クラスは必要def Start (): pass
def Start ():! hoge + bar pass
型の書き方
クラスは必要private _characterState as CharacterState
def CalculateJumpVerticalSpeed (targetJumpHeight as float):
def CalculateJumpVerticalSpeed (self, targetJumpHeight as float):
selfいらない→むしろ書くとエラーBCE0043: Unexpected token: self.
スタティックメソッドは?
HogeClass.StaticMethod()
public static def StaticMethod(): !Debug.Log("StaticMethod")
これをHogeClass内部へ作成
呼び出し方法
|| とか && とか
クラスは必要if moveSpeed < walkSpeed * 0.9 and grounded or hoge:
&& より and のほうが1バイト多くなる・・。
インデントに注意
クラスは必要if hoge: something # 半角スペース2つ
aaa #タブ
if fuga: something # 半角スペース4つ bar #インデント3つ
おそらくPython使いは半角スペース4つ
ご静聴有難う御座いました。