3

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.

2 Answers 2

6

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I tested it on Android Device. Thats why I didn't see it.
@David Oh I see. Check my Edit for that.
0
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()
    {

    }
}

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.