Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Argenex · Dec 05, 2010 at 10:13 PM · screenguitextprint

Print Anything to Screen

I have been desperatly trying to count a game object and its instantiated clones into an array, then print the result (counting) to the screen.

First I will ask about printing to screen, as simply printing text to screen doesn't even work. This is in javascript:

var helloText = "Hello World";

function OnGUI () {
GUI.Label (Rect (10, 10, 100, 20), helloText); }

There is no result anywhere on any screen for this. Is there some option somewhere to enable GUI? Thanks.

OK question answered. In order for scripts to print to the editor.log file, the console, or the Screen, they must be attached to a gameobject.

Thanks guys.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Argenex · Dec 05, 2010 at 10:32 PM 0
Share

i've tried print() and debug.log (only to editor.log). nothing prints anywhere, not even to the editor.log file, I'll see my script in the editor log run, and nothing else. Nothing prints to console either.

avatar image Argenex · Dec 05, 2010 at 11:06 PM 0
Share

Getting rather dismayed that its this complex to simply print text to the screen.

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Dec 05, 2010 at 11:11 PM

You have to attach scripts to objects if you want them to do anything; your script works fine if you attach it to something.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Argenex · Dec 05, 2010 at 11:24 PM 0
Share

Yea it displays now in the console, but still nothing on screen.

avatar image Justin Warner · Dec 06, 2010 at 06:06 AM 0
Share

Like he said, it doesn't work...

avatar image Eric5h5 · Dec 06, 2010 at 06:49 AM 0
Share

Works fine here.

avatar image Justin Warner · Dec 06, 2010 at 06:11 PM 0
Share

Sorry Eric, I think I totally read your answer wrong...

You're right, heres a sample project: http://rapidshare.com/files/435300496/New_Unity_Project_31.rar

I think I read his code wrong...

avatar image Argenex · Dec 07, 2010 at 06:45 AM 0
Share

I apologize I got lost in doing stuff, soon as I tied it to the object it worked. Feel kinda silly!

avatar image
0
Best Answer

Answer by boymeetsrobot · Dec 05, 2010 at 10:44 PM

Debug.Log("My Text"); should print to the console. Try doing it in the gameObject awake method to test:

void Awake()
{
Debug.Log("My Text");
}
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Argenex · Dec 05, 2010 at 11:04 PM 0
Share

is that for Csharp? cause that just has a whole ton of errors with it in js.

avatar image
0

Answer by Justin Warner · Dec 06, 2010 at 06:05 AM

Hey man, Make it a String, then output the string in a text.

var text:String[]=[ "HOW EVER", "MUCH STUFF", "YOU WANT", "GOES HERE"] ;

function BeginPage(width,height) { GUILayout.BeginArea(Rect((Screen.width-width)/2,(Screen.height-height)/2,width,height)); }

function ShowText() { BeginPage(300,300); for (var texts in text) { GUILayout.Label(credit); } for (var texts in crediticons) { GUILayout.Label(texts); } EndPage(); }

function Update () { ShowText();

}

That should work good enough!

Oh yes, this is altered from: http://www.unifycommunity.com/wiki/index.php?title=PauseMenu

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eric5h5 · Dec 06, 2010 at 06:51 AM 0
Share

That won't work at all; you can't call OnGUI functions from Update, plus you have no EndPage function.

avatar image Justin Warner · Dec 06, 2010 at 06:01 PM 0
Share

Works for me in my game...

And if you goto that link I put, it also has the endpage, I just did it quickly, and I think I know what you mean, but eh, it gets pretty close to what he wants.

avatar image Eric5h5 · Dec 07, 2010 at 07:34 AM 0
Share

No, it simply will not work to call OnGUI functions from Update. The code you posted will only generate an error (assu$$anonymous$$g you fix the missing stuff).

avatar image
0

Answer by Angelo101 · Dec 28, 2017 at 11:17 PM

[HELP] I am having a problem with my script as it will not print to console no matter what. -I made sure every icon in the right hand corner was turned on. -I made sure there was a GameObject in place. - I saved the script before execution.

What happened was that the unity console was working fine until all of a sudden unity froze on me for at least 20 min so I forced closed the program by restarting my computer. After that the unity console would not print anything. Nothing is wrong with my code I wrote exactly this:

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

public class NumberWizard : MonoBehaviour {

 // Use this for initialization
 void Start () {
     print("Hello");
 }
 
 // Update is called once per frame
 void Update () {
     
 }

} This code is all correct but the unity console wont print it. I apologize for the lack of screen shots since I do not know how.

Can anyone help?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

what is the correct way to display text on screen 1 Answer

How to Position a GuiText Prefab at Center of Screen 2 Answers

Gizmo-like GUi text? 2 Answers

Fit GUIText in every resolution 3 Answers

Viewing text when colliding, then canceling 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges