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 Esildorr · Apr 09, 2014 at 10:08 PM · instantiatestringgui-text

Edit String of instantiated Object then save it.

First Post!

I have a user instantiating an object at the location they are looking using ray casting. Once the object is placed they can click on it which opens a GUI box were they can input text into a string.

Here is the problem: After I instantiate one I can click on it and edit the string, no problem. After the second one is placed. I can click on it, and it opens the for mentioned GUI text box, i enter text into the text box, and it changes the string for the first one i created, leaving the second still set to null.

Code:

 function OnGUI()
 {
     if(editingHotspot == true)
         {
             //The Box
             GUI.Box(Rect(0,0,Screen.width+10,Screen.height+10),"Hotspot Editor");
             
             //Exit Button
             if (GUI.Button(Rect(Screen.width/2 - 150,Screen.height/2 + 20,120,30),"Save and Exit"))
             {    
                 editingHotspot = false;
             }
             
             //Name
             GUI.Label(Rect(Screen.width/2-400,Screen.height/2-230, 100, 30), "Enter Name:");
             hotspotName = GUI.TextField(Rect(Screen.width/2-400,Screen.height/2-200, 200, 25), hotspotName, 40);
             
         }
 }
 
 
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 robertbu · Apr 11, 2014 at 06:53 AM 0
Share

We need to see more of your code. In particular how hotspotName is used and how 'editingHotspot' gets set to true.

avatar image Esildorr · Apr 14, 2014 at 07:37 PM 0
Share

How "hotspotName" is used:

 //Declaring  
 var hotspotName : String;

How 'editingHotspot' gets set to true:

 function OnGUI()
 {
     //Checking to see if the users wants to edit Hotspot
     if(clicked == true && editingHotspot == false)
     {
         //Text
         GUI.Label(Rect(Screen.width/2,Screen.height/2,200,30),"Edit Hotspot?");    
         
         //Yes or No Buttons
         if (GUI.Button(Rect(Screen.width/2 - 90,Screen.height/2 + 20,60,30),"Yes"))
         {
             editingHotspot = true;
             clicked = false;
         }
             
         if (GUI.Button(Rect(Screen.width/2 + 30,Screen.height/2 + 20,60,30),"No"))
         {
             clicked = false;    
         }
     }
 }

P.S. 'editingHotspot' is a static bool from another script

1 Reply

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

Answer by Esildorr · Apr 15, 2014 at 07:07 PM

FIXED: the editingHotspot variable was static and because of that ALL of the GUI function were getting triggered to true, causing them to draw over each other. I just never realized it. This is also why i could only change the first one.

Thanks for everybody's time.

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

21 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

Related Questions

Checking if object intersects? 1 Answer

How to Instantiate from correct Icon. 1 Answer

Creating an Object with a string C#! How? 1 Answer

How do I instantiate a game object from a string variable? 2 Answers

How do you check if a string has already been removed from a generic list? 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