David
David

Reputation: 37536

Simple log in unity c# script

It should be simple, but still can't find a straight answer:

How can I log a simple message using C# Unity script?

I tried this:

Debug.Log("Hello Log");

It doesn't work or I'm not looking at the right place.

Upvotes: 3

Views: 712

Answers (2)

unpluggeDloop
unpluggeDloop

Reputation: 109

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

public class Simple : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Attach this script to component and simple message will be there  when you start project");
    }

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

    }
}

Upvotes: 0

Programmer
Programmer

Reputation: 125245

Debug.Log("Hello Log"); can be found on the Console Tab.

enter image description here


For you to be able to see it:

1.You must put it in a function from a script.

public class Test : MonoBehaviour
{
    void Start()
    {
        Debug.Log("Hello Log");
    }
}

2.Script must be attached to a GameObject.

enter image description here

3.Both the script and the GameObject it is attached to must be enabled.

enter image description here

4.Reset the Layout if you can't see the Console tab.

EDIT:

I tested it on Android Device. That's why I didn't see it.

In that case, use Android Monitor from Android Studio to view the log from your Android device.

enter image description here

Upvotes: 6

Related Questions