LoginSignup
0
1

More than 5 years have passed since last update.

【Unity】~SIerからゲーム業界へ~ 第3回 個人開発で終わらせないために

Last updated at Posted at 2018-08-23

ゲーム業界への転職が目的なので
個人での開発ではなく、複数人での開発や保守性、拡張性も意識しなければならないと思います。

今までの経験 + ネットでの事例を参考に徐々に実装していきます。
今後の実装予定のメモも兼ねて、随時更新予定です。

画面に開発情報を表示

開発者に必要な各種情報を見える化
とりあえずは画面に表示

今後の予定
・デバッグモードかどうかを設定ファイルで保持
 デバッグモード時のみ表示する
・画面に表示するだけではなく、どこかにログとして落としたい
 かつ、画面情報もキャプチャして落とすような仕組みにしたい

image.png

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class DebugDisplayLog : MonoBehaviour
{
    static public List<string> displayLog = new List<string>();

    private void Start()
    {
        this.oneSecondTime = 0f;
    }

    private void Update()
    {
        // FPS
        if (this.oneSecondTime >= 1f)
        {
            this.fps = this.fpsCounter;
            this.fixedFps = this.fixedFpsCounter;

            // reset
            this.fpsCounter = 0;
            this.fixedFpsCounter = 0;
            this.oneSecondTime = 0f;
        }
        else
        {

            this.fpsCounter++;
            this.oneSecondTime += Time.deltaTime;
        }

        // structure debug string
        this.debugString = "";
        int count = DebugDisplayLog.displayLog.Count;

        for (int i = 0; i < DebugDisplayLog.displayLog.Count; i++)
        {
            this.debugString += DebugDisplayLog.displayLog[i];
            this.debugString += "\n";
        }
        DebugDisplayLog.displayLog.Clear();
    }

    private void FixedUpdate()
    {
        this.fixedFpsCounter++;
    }

    private void OnGUI()
    {
        GUI.Label(
            new Rect(0f, 0f, Screen.width, Screen.height),
            "FPS: " + this.fps + "  FixedUpdate: " + this.fixedFps + "\n" + this.debugString);
    }

    // FPS
    private int fps;
    private int fpsCounter;

    // Fixed FPS
    private int fixedFps;
    private int fixedFpsCounter;

    // Debug Log
    private string debugString;

    // Timer
    private float oneSecondTime;
}

MonoBehaviourを継承

独自処理を実装しやすいように、ベースとなるMonoBehaviourを作成する

image.png
image.png

今後の実装予定機能

  • 他言語対応

テキスト表示するようなときがあれば、コードで書くのではなく別途ファイルで作成
別の言語にも容易に対応できるよう、日本語の場合だけでも言語コードもキーとして持たせる

  • 敵の設定情報など各種情報の外部ファイル化

コードの中で直接書かない。
エクセル、CSV、XMLあたりのファイルで持たせればいい?よく使われる適切な形式はこれから探す
ScriptableObject を使って設定クラスを作成する

  • デバッグモードを実装する

自分が無敵になる、敵がいなくなる、等のデバッグしやすい仕組みを事前に作成する

  • ドキュメントの作成

どの処理がどこに実装されてあるかなど、ドキュメントを作成する
その場合、フォルダ名とファイル名を工夫して容易に特定できるように意識する

0
1
2

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
1