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
1
Question by Fictional · Oct 28, 2014 at 06:32 PM · checkurlcurrent

Can I Read Domain Name?

Is it possible to know the current DOMAIN name and print as string, when an Unity game is loaded in a browser?

NOT URL(www.unity3d.com), I NEED DOMAIN NAME(unity3d). I try with Application.absoluteURL but I can't do it.

Is it possible? Thanks a lot.

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 Itaros · Oct 28, 2014 at 06:36 PM 0
Share

No one is obliged to help you even if you try hard with capital letters.

avatar image Bunny83 · Oct 28, 2014 at 07:06 PM 0
Share

@Fictional: I think you have no idea what a domain name is, right?

www.unity3d.com is the domain name. It's not an url.

This would be an url:

  http://www.unity3d.com/SomeResource
 |      |               |            |
 |   1  |       2       |      3     |

In this case the url only has 3 parts:

  1. The scheme or protocol

  2. The domain name or Host

  3. a path

If you just want to have "unity3d", that's just the second-level-domain-name part without the top-level and third-level parts.

  www.unity3d.com
 |   |       |   |
 | 3 |   2   | 1 |

  1. Is the top-level domain name

  2. Is the second-level domain name

  3. Is the third-level domain name

All 3 together form a complete domain name.

2 Replies

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

Answer by Bunny83 · Oct 28, 2014 at 06:56 PM

Uhm, the domain name is part of the url. The easiest way is to use the "Uri" class of Mono / .NET. Something like this:

 var uri = new System.Uri(Application.absoluteURL);
 Debug.Log("The domain name is: " + uri.Host);

If you need to access the top, second, third, ... level parts of the domain name independently, Just split them on the "."

 // C#
 var uri = new System.Uri(Application.absoluteURL);
 var parts = uri.Host.Split('.');
 System.Array.Reverse(parts); // reverse the array to make the last element the first
 for(var i = 0; i < parts.Length; i++)
 {
     Debug.Log("Level "+ i + " domain name:" + parts[i]);
 }

In UnityScript it looks the same, but since UnityScript doesn't have char-literals you have to use:

 var parts = uri.Host.Split("."[0]);
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
avatar image
0

Answer by Itaros · Oct 28, 2014 at 06:36 PM

Use string operations: http://msdn.microsoft.com/en-us/library/system.string%28v=vs.110%29.aspx

or regex :)

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Read Current URL 1 Answer

Locking levels on a level map? 1 Answer

check if each element in string is true simultaneously? 1 Answer

Do Objects Collide? 0 Answers

How do i check if a file exists (on the web)? 2 Answers


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