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
0
Question by amr nasr · Jan 12, 2011 at 10:11 PM · guitext

GUI Text Showing Gameobjects information

hi all, i need to build a game that will be informative , so that when i get closer to some game objects , it will show information about these objects that will be displayed on a GUI Text . How to do that ? any hints?

   if there is some scripts i will appreciate that.

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Justin Warner · Jan 12, 2011 at 10:32 PM

Psuedo:

Give objects you want with info a tag as info.

Make an array of objects with that tag by doing FindObjectsWithTag("info"); (I believe).

Have a toggle key (I'd do toggle key with the way that I'm saying), for this check input API, and if player pushes the key, check distances between that person and the gameobjects with the tag, and if the player is within distance, than show the GUI txt, or you can have a child of the object, and enable it that shows a material with the info above it...

Sorry, this is kinda messed up, I was going to delete it but figured you might find some use out of it, so I'll just post it, see what you can get from it.

Hope it helps though!

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
avatar image
0

Answer by Lab013 · Mar 18, 2011 at 06:51 AM

While Justin's idea would technically work, it would not be what I'd consider a good method.

Create a script called ObjectInformation. Have it look something like this:

var information : String = "";

Add this script to any object you want to have abstract information associated with it. Then in your player script, add this script:

function OnGUI() {

 var hit : RaycastHit;

 if (Physics.Raycast (transform.position, transform.forward, hit, 100.0)) { // The last parameter is the distance you want to test for
     var info : String = "size: ";
     info += hit.transform.localScale;
     info += "\nposition: ";
     info += hit.transform.position;
     info += "\nrotation: ";
     info += hit.transform.rotation;
     info += "\nabstract info: ";
     var objInfo : ObjectInformation = hit.transform.gameObject.GetComponent(ObjectInformation);
     if (objInfo) {
         info += objInfo.information;
     }

     else {
         info += "null";
     }

     GUILayout.Label("info");
 }

 else
     GUILayout.Label("No object found.");

}

Please don't be just another dumb copy and paste dev with no talent, respect, intelligence, or pride. Read and try to understand the code also.

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
avatar image
0

Answer by amr nasr · Jun 25, 2011 at 10:11 PM

Sorry i have been away from unity game engine but now i am back developing some games i have tried your script and it looks straight forward and simple , the usage of the ray cast is a smart idea from you .

Thanks man

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

1 Person is following this question.

avatar image

Related Questions

[JS] How to display an Int variable through a GUI Text?? [Resolved] 2 Answers

How do I reference a UI text in Unity 5? (JS) 2 Answers

Score wont show 0 Answers

How to create a review of previous updates 1 Answer

Using AutoType script on GUI.Label? 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