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 imagoculturae · Dec 15, 2014 at 04:38 PM · webplayerwebpagecss

Webplayer interaction between 3d scene and text on webpage

Is it possible to interact between the objects of a scene and the text contained in the same webpage(which contains the player).

As an example, let's say I want to change the color of an object by clicking the word "color" on the webpage.(later maybe I will have also some css with different a styles that will update also the 3d view)

How can I achieve this? What is the best approach? Many thanks

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
1

Answer by taxvi · Dec 15, 2014 at 05:46 PM

sure mate, read the Unity browser communication manual, should work

Comment
Add comment · Show 6 · 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 imagoculturae · Dec 15, 2014 at 10:10 PM 0
Share

Hi $$anonymous$$ate thanks a lot for your advice! Didn't see that before Just had a quick look at the manual and it looks pretty straight forward. At the moment in fact I am interested on how to Call unity webplayer content from the webpage(later I will do also the opposite).

 <script type="text/javascript" language="javascript">
 <!--
 //initializing the WebPlayer
 var u = new UnityObject2();
 u.initPlugin(jQuery("#unityPlayer")[0], "Example.unity3d");
 
 function SaySomethingToUnity()
 {
     u.getUnity().Send$$anonymous$$essage("$$anonymous$$yObject", "$$anonymous$$yFunction", "Hello from a web page!");
 }
 -->
 </script>
 

However I was thinking, what about when I will have a scene with many objects? Do I have to create a variable for each one? Is it better to use arrays? Do I have to do it manually for each object? I was thinking maybe somone out there as written some scripts or even just a methodology walktroghout. $$anonymous$$any thanks and sorry but I am not a programmer although I can go trought scripts.

avatar image taxvi · Dec 16, 2014 at 04:50 AM 0
Share

of course arrays are much more laconic. you can always use tags or layers to make things easier. create an empty object responsible only for communication with the browser. then in the communicator's start function use

 List<GameObject> myObjects = GameObject.FindObjectsWithTag("browserBased");

note that you need to import System.Collections.Generic to use Lists. and lists are just the same as arrays with flexible size, u can add remove stuff from it dynamically. then put your desired objects under the tag "braowserBased" and wolah!

avatar image taxvi · Dec 16, 2014 at 04:52 AM 0
Share

good thing is you'd need to call a single function from the browser. bad is you'd have to iterate through all the 'myObjects' on each call.

avatar image imagoculturae · Dec 16, 2014 at 09:54 AM 0
Share

Wow thanks a lot taxvi! I will give it a go and let you know if succeed. There are so many other things I would like to implement but this will come later. $$anonymous$$aybe I should start a blog/wiki on the topic so that I can collect all the information in one place, also for other people that need to work in this way, there are many fields(not only games) where a web interface is preferred to GUI and I could not see many project oriented in this direction (am I wrong?).

avatar image imagoculturae · Dec 16, 2014 at 05:39 PM 0
Share

Hi again, sorry... I did a quick test... I am using this into my page

 <script type="text/javascript" language="javascript">
 <!--
 //initializing the WebPlayer
 var u = new UnityObject2();
 u.initPlugin(jQuery("#unityPlayer")[0], "Example.unity3d");
 
 function SaySomethingToUnity()
 {
     u.getUnity().Send$$anonymous$$essage("$$anonymous$$yObject", "Colorchange", "");
 }
 -->
 </script>
 
 ...
 
 <button type="button" onclick="SaySomethingToUnity()">Click $$anonymous$$e!</button>

And this into my object script:

 function Colorchange () {
             // Set specular shader
     
         renderer.material.shader = Shader.Find ("Diffuse");
         // Set red specular highlights
         renderer.material.SetColor ("_Color", Color.red);;
     }


But nothing happen when I click the button.

???

Show more comments

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

28 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

Related Questions

Is there a way to get the page that my WebPlayer is embedded into? 2 Answers

Scale WebGL cavas to browser window size 0 Answers

Can I run a script in real time on a browser game? 1 Answer

Getting a standalone project to run on a webpage? 0 Answers

Google Native Client & Unity Web Player 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