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 james Tima_2 · Feb 04, 2014 at 12:59 PM · stringnguiclickable

Set URL as clickable in Lable string

Hi all,

How can we achieve this? I've a string with urls lets say "something http://www.google.com again http://www.amazon.com" or "http://www.google.com nexturl http://www.amazon.com". Now what I want is, when I am showing this string (in a UILabel), I could make the link clickable, i.e., the link should act like a url, so that when I click it, it should open me the respective link.

Please provide me your suggestions on how to achieve this. Also I am using NGUI for showing labels.

Thanks in advance.

EDIT : Found this on NGUI Forum, this is related to my ques but no help : [http://www.tasharen.com/forum/index.php?topic=7809.0][1] [1]: http://www.tasharen.com/forum/index.php?topic=7809.0 :(

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 james Tima_2 · Feb 06, 2014 at 09:52 AM 0
Share

Anyone please??? BU$$anonymous$$P!!!

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by GameVortex · Feb 04, 2014 at 01:02 PM

Detect button click normally like one always do in NGUI and then us **Application.OpenURL** to open the url:

 private void OnClick()
 {
     Application.OpenURL(url);
 }


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 james Tima_2 · Feb 04, 2014 at 01:08 PM 0
Share

Yes, this is correct, but actually my problem is : I am getting the above string as a response and I have to display this string as half text and half url (which can be clicked). So actually I wanted to achieve this first....then the clicking part could be done according to this!!!

avatar image GameVortex · Feb 04, 2014 at 01:16 PM 0
Share

You would have to separate out the url and display it on its own UILabel, or resize the collider for the UILabel yourself so it only covers the url.

avatar image james Tima_2 · Feb 04, 2014 at 01:47 PM 0
Share

Yes I found this the ONE way to display text and url as on their different UILabel's. But I am stuck in some situation...I mean what if the url string is bigger..and it then displayed/moved to the next line also..then how could I manage that Label's collider ..

avatar image
0

Answer by EdwardLM · Feb 06, 2014 at 08:10 PM

I can think of two different approaches

· Limit the URL size, with the default options of "size" or just adjusting the .text variable of that UILabel to do whatever you want. For example: when the size of a URL exceeds 30 characters, replace the last characters for "(...)"

· Put only one UILabel, it will have the entire text + URL. Over it, there will be an invisible button the size of the URL. You will have to position this invisible button exactly on the top of URL. To me, this seems a bit more "dirty", but if this is only for an isolated case and not meant to be reused in the rest of the project, it may work for you.

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

20 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Why do I have to call ToString() when fetching a String from another script? 2 Answers

How to tell if a string contains some specified text 6 Answers

How do I find font by passing a string? 1 Answer

Combining several strings into a single one? 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