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 AR_Rizvi · Oct 14, 2013 at 06:31 AM · collisionguipositionongui

Script is not working help plz

i wrote a simple script which works on colision and showa the name of the pbject that Controller collided with but it is not working i am geeting the message of objects name on console but it is not showing on Gui plz can anyone tell me what i am doing wrong here is the code

 #pragma strict
 var Pos:Vector3;
 public var  Rname : String;
 public var  R_name : String;
 var  player :GameObject;
 var activeChild : GameObject;
 var showLOc : boolean;
 var str : String;
 
  function Start()
  {
     player = GameObject.FindWithTag("Player");
       
       activeChild = transform.gameObject;
       
       
  } 
  function OnTriggerEnter (hit : Collider) 
     {
     
 //        if(hit.gameObject.tag == "MainCamera")  
         Rname =    hit.transform.name;    
         Debug.Log("name "+Rname );
         
 
     }
 
 function OnGUI () 
 { 
 
   Debug.Log("on gui fnc "+Rname );
     
 
       if(showLOc)
     {
              
            
           
          Pos =    activeChild.transform.position;
      
      GUI.Label (Rect(110,Screen.height-40,550,70), "Region:" + Pos.ToString());
      
      
      GUI.Label (Rect(110,Screen.height-60,550,70), "Region:" + Rname);
      str = null;
      
          
      }
  
 }
 
 function Update () 
 {
     if (Input.GetKeyDown(KeyCode.C)) 
         showLOc = !showLOc;
         setlayer();
 }
 
 
 
 function setlayer()
 {
     for (var child : Transform in player.transform)
     {
         if(child.active)
             activeChild = child.transform.gameObject;
             
     } 
 }

Thanks AR

Comment
Add comment · Show 6
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 Doireth · Oct 14, 2013 at 07:34 AM 0
Share

What is showing on the GUI?

avatar image tanoshimi · Oct 14, 2013 at 07:47 AM 0
Share

Are you remembering to press "C" first to toggle the GUI display? What does the setlayer() function do? Is any guidisplayed? And what's the purpose of the str variable? (which always appears to be null)

avatar image meat5000 ♦ · Oct 14, 2013 at 07:53 AM 0
Share

Does Debug.Log("name "+Rname ); work?

avatar image AR_Rizvi · Oct 14, 2013 at 10:09 AM 0
Share

yup i remember to press c of course and Str is Null i forget to delet that Set layer is capturing the active child of my character controller as i have 3 cameras in it fr different purpose

and yup Debug is working in On Trigger function but not working in OnGui

and position is being printed in gui and just Region: but not the name of the object i am colliding with

avatar image AR_Rizvi · Oct 14, 2013 at 10:11 AM 0
Share

and i do remember to check the is trigger box of my collider to but the Value in Rname is not wotking in On Gui function i dnt knw why

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

17 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

Related Questions

Setting Scroll View Width GUILayout 1 Answer

Question about positioning GUI. 1 Answer

why is my GUI script bugging other GUI scripts? 0 Answers

Drawing a GUI box by specifying the two corners 1 Answer

destroy touch the screen on gameobject in camera 0 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