Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Simple question I can't find the answer too. Please help

Discussion in 'Scripting' started by xXGogreen642Xx, Jan 1, 2016.

  1. xXGogreen642Xx

    xXGogreen642Xx

    Joined:
    Dec 27, 2015
    Posts:
    4
    Hello and if you're reading this thanks for your help in advance. I'm new to everything I'm trying to do. Unity, c#, programming in general. Anyway I'm beginning to understand some of the basic syntax and the unity gui ect. However I'm having problems all of the sudden with trying to display any text on the console. I've done the "hello world" project before on the same pc with success but as of late I'm unable to get it to work no matter what I try. I was just starting to move on to more advanced problems when I tried to display something to the console I was almost sure I was doing right and now it didn't work. My code is as follows, just a simple hello world which displays no errors, yet shows nothing in the console.

    using UnityEngine;
    using System.Collections;

    public class helloworld : MonoBehaviour
    {
    void start()
    {
    print ("hello world");
    }
    }

    Like I said above I'm fairly sure that is correct. Also I've tried other resources before coming here so please help if possible. I've read on other threads and my console is not collapsed and all 3 of the boxes on the top right of the console are off also (the ones that allow messages, warnings, and errors). If anyone has had a similar problem or knows how I could fix this please reply below. Thank you for your time and hopefully someday I can be able to help answer dumb questions like this one once I understand what I'm doing.

    BTW: I've also tried completely re-installing unity and got the same results using both 2d and 3d presets
    giving the script to both empty game objects, sprites, and 3d objects with no success.
     
  2. Afrodeity

    Afrodeity

    Joined:
    Dec 19, 2015
    Posts:
    12
    You have to assign the script to an object in your scene for it to execute.
     
  3. xXGogreen642Xx

    xXGogreen642Xx

    Joined:
    Dec 27, 2015
    Posts:
    4
    Thanks for trying to help but i did. Ive tried assigning it to empty objects, sprites and 3d objects.
     
  4. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    Change print to
    Debug.log
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You need to write code exactly. A function called "start" won't do anything; it needs to be "Start". Use code tags when posting code here.

    --Eric
     
    Magiichan likes this.
  6. Magiichan

    Magiichan

    Joined:
    Jan 5, 2014
    Posts:
    403
    As @Eric5h5 said, it needs to be like this
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class helloworld : MonoBehaviour
    5. {
    6.    void Start()
    7.    {
    8.       print ("hello world");
    9.    }
    10. }
    Be sure to pay attention to the names. Everything is case sensitive...
     
  7. xXGogreen642Xx

    xXGogreen642Xx

    Joined:
    Dec 27, 2015
    Posts:
    4
    Ohhh.. like I said.. I knew it was a stupid question. I was aware that c# is case sensitive I just didn't know start was capitolized. Thanks for all the help guys :)
     
  8. xXGogreen642Xx

    xXGogreen642Xx

    Joined:
    Dec 27, 2015
    Posts:
    4
    How do you reply with your code in the box like that? I'm new to the forums
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401