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
2
Question by Orthone · Dec 01, 2011 at 07:26 PM · guitextarea

Location of a char in a String

I'm currently having trouble figuring out how to replace certain text in my GUI with a button. I'm parsing it out correctly, and getting the correct dimensions, but I can't for the life of me figure out how to find the X and Y coordinate of the first character that I'm parsing out. Any help or point in the right direction would be greatly appreciated.

Resolved~ Result: http://dl.dropbox.com/u/18867763/Unity/StoryTeller/WebPlayer/WebPlayer.html Code

var buttonLocationRect = Engine.Skin.textArea.GetCursorPixelPosition(Engine.BoxRect), new GUIContent(infoString), infoString.IndexOf('<'));

Comment
Add comment · Show 1
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 aldonaletto · Dec 01, 2011 at 11:00 PM 0
Share

What exactly are you trying to do? This GUI, is it a GUIText or some GUI system object (GUI.Label, GUI.Button etc.)? And about which X and Y coordinate are you talking? Screen coordinates? Finding the position of some single character in Unity seems impossible to me.

1 Reply

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

Answer by jahroy · Dec 01, 2011 at 11:15 PM

Is that what these functions are for?

  • http://unity3d.com/support/documentation/ScriptReference/GUIStyle.GetCursorStringIndex.html

  • http://unity3d.com/support/documentation/ScriptReference/GUIStyle.GetCursorPixelPosition.html

I don't know the answer to that question.

It sounds like these functions might do what you want, but the documentation is so brief it's hard to tell.

Comment
Add comment · Show 3 · 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 aldonaletto · Dec 02, 2011 at 12:12 AM 0
Share

Good job, @jahroy! Now finding the position of any character seems possible to me - at least in the GUI system (not so easy, given the laconic description in the docs).

avatar image Orthone · Dec 02, 2011 at 12:14 AM 1
Share

If these do work, and I'll try them as soon as I can, it'll be a lot simpler than the way I had figured out. Thanks.

Edit: Yes! It works exactly how I need it!

avatar image jahroy · Dec 02, 2011 at 02:21 AM 0
Share

That's great news. I was hoping that's what they did, but haven't gotten a chance to play with them yet.

Cheers for another reason to love Unity Answers... You just paste a link up and get immediate proof of concept!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

UnitySerializer Delete Saved Games 0 Answers

How do I center the gui created by this script? 0 Answers

Score Help (Im new) 1 Answer

Switching lines on gui text area 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