Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Chocolade · Dec 06, 2016 at 11:18 AM · c#scripting problemscript.

How can i make a text changed event in EditorGUILayout.TextField ?

 void OnGUI()
     {
         GUILayout.Label("Base Settings", EditorStyles.boldLabel);
         objectsName = EditorGUILayout.TextField("By Name", objectsName);
 
         groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);
         myBool = EditorGUILayout.Toggle("Toggle", myBool);
         myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3);
         EditorGUILayout.EndToggleGroup();
 
         GUILayout.FlexibleSpace();
         
         EditorGUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         GUI.enabled = false;
         if (GUI.changed)
         {
             GUI.enabled = true;
         }
         if (GUILayout.Button("Name"))
         {
             
         }
         EditorGUILayout.EndHorizontal();
     }

I want to make that if i type something inside the EditorGUILayout.TextField it will enable the button and if it's empty then disable again the button.

I tried this part:

 GUI.enabled = false;
             if (GUI.changed)
             {
                 GUI.enabled = true;
             }

It's changing it to false the button but never change it back to true. I want when i type anything in the EditorGUILayout.TextField it will enable true the button the "Name" and if i will delete the text from the EditorGUILayout.TextField it will enable false the button again.

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 tomekkie2 · Dec 06, 2016 at 12:54 PM

Try this:

     string objectsName = "";
     void OnGUI()
          {
              GUILayout.Label("Base Settings", EditorStyles.boldLabel);
              objectsName = EditorGUILayout.TextField("By Name", objectsName);
      
              groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);
              myBool = EditorGUILayout.Toggle("Toggle", myBool);
              myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3);
              EditorGUILayout.EndToggleGroup();
      
              GUILayout.FlexibleSpace();
              
              EditorGUILayout.BeginHorizontal();
              GUILayout.FlexibleSpace();
              EditorGUI.BeginDisabledGroup (objectsName == "");
              if (GUILayout.Button("Name"))
              {
                  
              }
              EditorGUILayout.EndHorizontal();
              EditorGUI.EndDisabledGroup ();
          }


Comment
Add comment · Show 4 · 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 Chocolade · Dec 06, 2016 at 03:49 PM 0
Share

This is working but when i display the window the button is starting as enabled true. Then when i type something and delete it the button is enabled false. How can i make that the button will start by default as enabled false ? And then when i will type something it will be enabled true and when delete enabled false again.

avatar image tomekkie2 Chocolade · Dec 06, 2016 at 04:27 PM 0
Share

Try again with

EditorGUI.BeginDisabledGroup

I have corrected the above code. If that works, I cound convert it to answer.

avatar image Chocolade tomekkie2 · Dec 06, 2016 at 04:55 PM 0
Share

It's working the other way now. The wrong way.

When i display the window the button is enabled false but then when i type something the button still false then when i delete the text the button enable true then if i type again the button is false.

avatar image tomekkie2 Chocolade · Dec 06, 2016 at 05:04 PM 0
Share

Ah sorry!!! should be == ins$$anonymous$$d of !=

 EditorGUI.BeginDisabledGroup (objectsName == "");

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

254 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 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 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 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 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 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 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 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 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 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

Why when creating new animator controller for the character the character is not walking right ? 0 Answers

How can i Instantiate on the terrain from left to right ? 0 Answers

Why the tile map scripts take almost all the cpu usage ? cpu usage is getting to 99% at times 1 Answer

How can i rotate object by pressing on key R and keep object facing to me my self ? 0 Answers

Why it;s never getting to the OnMouseDown function when clicking with the mouse ? 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