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 Robomaster · Jun 14, 2012 at 10:58 PM · enable3d textdisabledselecting

Scripting error

what im trying to do is make it so that when i click on the menu icon it displays or enables the 3d text. But when it's not selected the 3d text is disabled. Can anyone help with me with this code and tell me whats wrong.

P.S. Options is the 3D text name.

   using UnityEngine;
 using System.Collections;
 
 public class GameTabs6 : MonoBehaviour {
      GameObject Options;
 
 void OnGUI(){
 if (GUI.Button(new Rect(100,0,50,25), "Menu")){
 GetComponent<GameaTabs5>().enabled = false;
 GetComponent<GameTabs3>().enabled = false;
 Options.renderer.enabled = true;
 
 }
 }
 }
     
     
     
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

1 Reply

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

Answer by whydoidoit · Jun 14, 2012 at 11:00 PM

If you have the game object on which the text is located then this will do it:

 gameObject.renderer.enabled = false; //or true
Comment
Add comment · Show 28 · 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 Robomaster · Jun 16, 2012 at 01:06 AM 0
Share

Its is just 3d text under gameobject moved to a part of the screen i want it to be at. when i used that script it said

There is no 'Renderer' attached to the "$$anonymous$$ain Camera" game object, but a script is trying to access it. You probably need to add a Renderer to the game object "$$anonymous$$ain Camera". Or your script needs to check if the component is attached before using it.

avatar image whydoidoit · Jun 16, 2012 at 01:09 AM 0
Share

Ah - I thought you had a reference to the 3D text you wanted to hide.

You'll need one of them Define it at the class level and drag and drop your object onto it in the inspector.

   var textObject : GameObject;

   ...

   textObject.renderer.enabled = false; // or true
avatar image Robomaster · Jun 16, 2012 at 01:15 AM 0
Share

let me give you what i coded

gameObject.renderer().enabled = true;

P.S. Options is a 3d text for the side menu. I want it to be off when your clicking on something else but when you click on menu it's turned on.

avatar image Robomaster · Jun 16, 2012 at 02:01 AM 0
Share

thanks for responing so quickly aslo is that javascript or c#

avatar image Mizuho · Jun 16, 2012 at 04:24 AM 0
Share

@Will467: var textObject : GameObject is a Javascript declaration. The C# equivalent is GameObject textObject;.

Show more comments

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

enable disabled GameObjects 1 Answer

Gui.Enable transperancy 4 Answers

disable/enable Mouse Look(c#) with a script of js 7 Answers

Disabled colliders picked up by OnTriggerEnter 0 Answers

Disable gun if it is not mine? 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