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 spinnerbox · Dec 22, 2015 at 01:30 PM · webplayerexternalhtml5application.openurl

Building game rewrites web.html page

I wanted to make my game open url page but in separate tab instead of the same window as my web build, so I made a function that does that by using Application.ExternalCall () function in unity.

Though the code works and the page is oppened in new tab, when I build my game, web.html page is rewriten from scratch using some default code template, i.e my code disappears.

Is there a way how to prevent this from happening or is there a place where I can edit what is generated by default in the web.html page?

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

2 Replies

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

Answer by spinnerbox · Dec 22, 2015 at 01:52 PM

You can define a web page to serve as a template for your web build in future. Here is the page where I found this info: http://docs.unity3d.com/Manual/UsingWebPlayertemplates.html

Create a folder called WebPlayerTemplates in your assets folder and then create another folder which will hold all files about the specific template. You can have multiple web templates and once you restart your Unity and reload your project, the templates will appear in Build Settings -> Player Settings -> Web Player.

The template must have index.html page and you can create thumbnail.png, 128x128 to serve as image in the templates section in Unity.

Was about to delete the question but it is useful so... :)

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
1

Answer by phil_me_up · Dec 22, 2015 at 01:42 PM

I've not done this for web games, but I would have thought you could make a PostProcess script that would open the html file and replace the contents.

Examples: http://docs.unity3d.com/ScriptReference/Callbacks.PostProcessBuildAttribute.html Note it's the [PostProcessBuild(x)] attribute that actually tells this to run once the build has completed. x should be replaced by the order you want this to run (so something where x=1 will run before something with x=200)

Here's a pretty together sample (sorry for errors if there are any, it's off the top of my head)

 public static class cChangeSomething {
 
     [PostProcessBuild(200)]
     public static void OnPostProcessBuild(BuildTarget target, string path)
     {
             ChangeSomething (path);
     }
 
 
     public static void ChangeSomething(string path)
     {
         string fullPath = Path.Combine(path, Path.Combine(Path.Combine("Folder1", "Folder2"), "myfile.html"));
         string data = Load (fullPath);
 
         string wholeStatement = "This is the text you want to insert";
         data = Regex.Replace (data, @"This is the text you want to replace", wholeStatement);
         
         Save (fullPath, data);
 
     }
 }
Comment
Add comment · Show 2 · 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 spinnerbox · Dec 22, 2015 at 01:48 PM 1
Share

Good point. I might use this for more advanced builds in future. However after a simple search about web.html and unity I found this page: http://docs.unity3d.com/$$anonymous$$anual/UsingWebPlayertemplates.html :)

avatar image phil_me_up spinnerbox · Dec 22, 2015 at 01:50 PM 0
Share

That looks like a much nicer solution! Wasn't aware this existed but I'll keep it in $$anonymous$$d if I ever build for web.

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

33 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

Related Questions

Application.OpenURL not working with Data URI 1 Answer

Using web players in different browsers 1 Answer

Unity webgl or threejs or babylonjs ? Which one is the best for me? 1 Answer

Having trouble publishing my Unity Game on Facebook 1 Answer

Chrome dropping NPAPI support 0 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