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 Aubrey-Falconer · Dec 28, 2010 at 07:47 AM · javascriptguiguilayout

"'UnityEngine.GUI.DoTextField' is inaccessible due to its protection level."

I found a very cool snippet of code by Shaun on this page: http://forum.unity3d.com/threads/14505-non-selectable-textarea

And tweaked it a bit to come up with this:

    var searchFieldID : int = GUIUtility.GetControlID(FocusType.Keyboard);
    var searchFieldRect : Rect = GUILayoutUtility.GetRect((worldListFilter == "" ? 400 : 255), 28, "textfield");
    var worldListFilterGUI : GUIContent = GUIContent(worldListFilter);
    GUI.DoTextField(searchFieldRect, searchFieldID, worldListFilterGUI, false, (worldListFilter == "" ? 400 : 255), "TextField");
    worldListFilter = worldListFilterGUI.text;
    if (!searchFieldRect.Contains(Event.current.mousePosition) && GUIUtility.keyboardControl != searchFieldID && String.IsNullOrEmpty(worldListFilter))
        GUI.Label(searchFieldRect, "Title, Author, or Description","textfieldhint");

It's supposed to display a search field UI style alt text when the user isn't ineracting with the field, but alas - won't compile and instead Unity throws an "'UnityEngine.GUI.DoTextField' is inaccessible due to its protection level" error.

Any ideas?

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 Eric5h5 · Dec 28, 2010 at 07:56 AM

There is no GUI.DoTextField function. Or rather, there is, but it's private (as the error basically says). Private APIs can no longer be accessed in Unity 3, so they might as well not exist...they were never intended to be used by user code in the first place, and are subject to change at any time.

Comment
Add comment · Show 1 · 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 Aubrey-Falconer · Dec 30, 2010 at 06:20 AM 0
Share

Too bad. I nearly drove myself insane yesterday trying to set up a live search field that didn't loose focus as soon as the user entered the first char. Whenever the user would enter something, the rest of the GUI would change - and this would cause the field's id to change, and this would cause the field to loose focus. I could detect this and re-add the focus as the user was typing, but it would select everything in the field and clear the text they had already entered. Incredibly annoying, and I couldn't find any way to work around it...

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

No one has followed this question yet.

Related Questions

Setting Scroll View Width GUILayout 1 Answer

Reverse GUILayout 1 Answer

For Loop GUILayout.Label Problems 1 Answer

Open gui if player clicks on button 2 Answers

Unity freezes when changing GUI.Color.a 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