LoginSignup
1
4

More than 5 years have passed since last update.

UnityのDebug.log()でHelloWorldを出力しました

Last updated at Posted at 2014-11-23

UnityでDebug.log()を使い、HelloWorldを出力したいと思いました。

デバッグログの書き方

Debug.log()で書きます。

Debug.Log ("HelloWorld");

スクリプトを作りHelloWorldを記述

Project > Create > C# Scriptを選択し、C#スクリプトを作成します。
ファイル名を「HelloWorldScript」と名前を付けました。

HelloWorldを表示
using UnityEngine;
using System.Collections;

public class HelloWorldScript : MonoBehaviour {

    // Use this for initialization
    void Start () {
        Debug.Log ("HelloWorld");
    }

    // Update is called once per frame
    void Update () {

    }
}

スクリプトを作成するとひな形が最初から用意されているので、そのvoid Start()内にDebug.log()を記述します。

GameObjectとスクリプトを紐付けする

GameObject > Create Empty で空のGameObjectを作成します。
HierarchyにあるGameObjectへ、ProjectのAssetsにあるHelloWorldScriptをドラッグ・アンド・ドロップします。

GameObjectがHelloWorldScriptと紐付けされています。

HelloWorld!を表示

ゲームビューでプレビューします。
コンソールログにHelloWorldが表示されています。

ちゃんとHelloWorldを表示できました。

1
4
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
1
4