Programming」カテゴリーアーカイブ

プログラミング全般に関するカテゴリーです。

Unityの画面を録画するアセット

以前、Unityで作ったゲームのScreenshotMovieを作成できるスクリプトを試してみましたが、もう少し本格的に録画したい場合は「Unity Recorder」というアセットが良さそうな感じでした。

GitHub – Unity-Technologies/GenericFrameRecorder: Recorder framework that allows recording anything in unity.
https://github.com/Unity-Technologies/GenericFrameRecorder

こちらも連番画像ファイルの形式になりますので、必要に応じてFFmpegなどで動画ファイルに変換してください。

リンク

Recorder – Asset Store
https://assetstore.unity.com/packages/essentials/beta-projects/recorder-94079

Unityの街並みジェネレーターアセット

適当な街並みを自動生成してくれるUnityのアセット「TekitouCityGenerator」。

tekitou-city-generator-1
tekitou-city-generator-2

テスト・プロトタイプでの利用を想定して作られたアセットだと思いますが、本番用途で使えそうなクオリティだと思います。

比較的軽めなのでスマホゲーに良いかもしれません。

リンク

GitHub – Maruchu/TekitouCityGenerator: 適当な街並みを作るUnity5のサンプルプロジェクト
https://github.com/Maruchu/TekitouCityGenerator

C#の自作クラスでforeachを使う

C#の自作クラスでforeachを使いたい場合はGetEnumeratorというメソッドを追加してみれば良いようです。

public class Example : MonoBehaviour
{
  public IEnumerator<string> GetEnumerator()
  {
    yield return "A";
    yield return "B";
    yield return "C";
  }
}

こんな感じにすると、

Example example = new Example();

foreach(string s in example) {
  Debug.log(s);
}

のように使えます。

リンク

How to use foreach keyword on custom Objects in C# – Stack Overflow
https://stackoverflow.com/questions/348964/how-to-use-foreach-keyword-on-custom-objects-in-c-sharp