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 /
This question was closed Jul 17, 2014 at 04:25 PM by Graham-Dunnett for the following reason:

Duplicate Question

avatar image
0
Question by Imagineer · Apr 06, 2014 at 09:13 AM · errorrectcs1502cs0119cs1503

Gui label errors

I used this code (and similar but with the same errors). I also tried GuiLayout.label

 GUI.Label(Rect(10,10,100,30),"Test");

The errors that I get:

Assets/Scripts/NetworkManager.cs(15,27): error CS0119: Expression denotes a type', where a variable', value' or method group' was expected

Assets/Scripts/NetworkManager.cs(15,21): error CS1502: The best overloaded method match for UnityEngine.GUI.Label(UnityEngine.Rect, string)' has some invalid arguments Assets/Scripts/NetworkManager.cs(15,21): error CS1503: Argument #1' cannot convert object' expression to type UnityEngine.Rect'

I was using this script also without any errors but here I can't see the text..

 using UnityEngine;
 using System.Collections;
 
 public class NetworkManager : Photon.MonoBehaviour {
 
     
 
     void Start ()    
      {
         PhotonNetwork.ConnectUsingSettings("alpha 0.1");
     }
     
     void OnGui()
     {
         GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
     }
     
     void OnJoinedLobby()
     {
         PhotonNetwork.JoinRandomRoom();
     }
     
     void OnPhotonRandomJoinFail()
     {
         PhotonNetwork.CreateRoom(null);
     }
 }
Comment
Comments Locked · 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 Lo0NuhtiK · Apr 06, 2014 at 09:55 AM 0
Share

Almost the same damn question was asked in THIS TOPIC earlier today, and probably countless other ones over the years.

By the way.. you mention in one of your comments below here that adding the "new" keyword to a GUI.Label has gotten rid of your error but now you cant see it still... Try capitalizing OnGUI() properly.

avatar image Imagineer · Apr 06, 2014 at 10:36 AM 0
Share

That was the trick! Thanks :D I used OnQui ins$$anonymous$$d of OnGUI...

4 Replies

  • Sort: 
avatar image
2
Best Answer

Answer by deltamish · Apr 06, 2014 at 09:23 AM

Hi thats really simple all you got to do is add "new" syntax before the Rect

 GUI.Label(new Rect(10,10,100,30),"Test");
Comment
Comments Locked · Show 2 · 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 Imagineer · Apr 06, 2014 at 09:27 AM 0
Share

This gets rid of the errors but I cant see the text now...

avatar image deltamish · Apr 06, 2014 at 09:52 AM 0
Share

are you sure Try maximizing the screen view this code should work

avatar image
2

Answer by Eric5h5 · Apr 06, 2014 at 11:14 AM

There is no built-in function called "OnGui". https://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnGUI.html

Comment
Comments Locked · 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
1

Answer by drudiverse · Apr 06, 2014 at 09:21 AM

you probably forgot OnGui function...

check this page, and also read through the other GUI elements it's handy. you do a loop in ongui to create many gui elements in one frame as well by looping their rect position.: https://docs.unity3d.com/Documentation/ScriptReference/GUI.Label.html

Comment
Comments Locked · 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 Imagineer · Apr 06, 2014 at 09:26 AM 0
Share

Thanks for the reply, but I do have a void OnGui...

avatar image
0

Answer by Nequium · Apr 06, 2014 at 10:56 AM

Change your code to:

GUI.Label(new Rect(10, 10, 100, 30), "Test");

You must have the "new" keyword before Rect if you are coding in C#.

Comment
Comments Locked · 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

Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

ScriptableWizard Problem with LoadAssetAtPath 1 Answer

Unity Errors 1 Answer

Error CS1525 calling OntriggerEnter 1 Answer

Whats wrong with my script? GUI C# 2 Answers

Expression denotes a 'type', where a 'variable', 'value' or 'method group' was expected, and 2 other errors. 2 Answers


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