0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

コードリーディング (Pro Builder - Sample - Runtime - RuntimeEditing - Scripts - CameraMotion) 1ノ巻

0
Last updated at Posted at 2019-11-17

Unityのコードを読んでみます。
読むのは、com.unity.probuilder/Samples~/Runtime/Runtime Editing/Scripts/CameraMotion.csです。
これを選んだ理由は特にありません。

https://github.com/Unity-Technologies/com.unity.probuilder/blob/master/Samples~/Runtime/Runtime%20Editing/Scripts/CameraMotion.cs
こちらにソースコードがあります。

読む

先頭コメント

まずコメントがあるのですがその内容はUnify wikiにあるFlyThrough.jsを部分的に使用していますという内容です。
http://wiki.unity3d.com/index.php/Main_Page
に参考したものが乗っています。

こんなサイトがあるのですね。初めて知りました。

インポートしている名前空間

  • UnityEngine.
  • UnityEngine.Assertions
  • UnityEngine.EventSystem
Assertions

アサーションに関係するものがまとめてある。
アサーションとは日本語でいうと表明。(これの使いかた、オブジェクト思考入門の契約によるプログラミングのところに色々とかいてあった気がする。。。)
プログラム内で保証されることをかく。早期のバグ発見を目的としている。
ex
Assert.IsFalse(health < 0);
HPが0より小さくなることはおかしいよということを主張している。
これのいいところは開発環境で適用されるが、実際にビルドされる時は向こうになる。
(BuildOptions.ForceEnableAssertionsを有効にしない限り。)

保証されるべきルールに違反していた場合は、通常はログメッセージを表示するだけだがAssert.raiseExceptionsを有効にすると例外が投げられるようになる。
デバッガーを利用している時もポーズするために例外が投げられる。

公式ドキュメント
https://docs.unity3d.com/ja/2017.4/ScriptReference/Assertions.Assert.html

EventSystem

https://docs.unity3d.com/ja/2017.4/Manual/EventSystem.html
こちらに細かい解説があります。

自分メモ
イベントシステムを知らなかったので調べる。
アサーションのベストプラクティスとか調べたら出てくるはずなので調べる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?