- Home /
Browser communication example problem
Hello i am new to Unity.I have unity 5 and builded simple project with it.I wrote a javascript code that has function named MyFunction takes string paramater and attached it to Canvas.This canvas had created when i added Component-->UI-->Text to scene. Canvas has a child component Text that i see on game screen.I can change Text inside of it when debugging.Now i want this text on the scene change according to javascript code example using Html.However there are problems i counter when i try to see some results. This is my NewBehaviourScript.js.I try to understand if MyFunction is ever used if used i will see 1 on screen.
Using javascript example i modified the code below.Example of unity:http://docs.unity3d.com/Manual/UnityWebPlayerandbrowsercommunication.html
<script type="text/javascript" language="javascript">
//initializing the WebPlayer
var u = new UnityObject2();
u.initPlugin(jQuery("#unityPlayer")[0], "denemeunity.unity3d");
function SaySomethingToUnity()
{
if(u.getUnity()){
alert("hey");
u.getUnity().SendMessage("Canvas", "MyFunction", "Deneme");
}
}
SaySomethingToUnity();
</script>
However i believe u.getUnity() doesnt work.Even if i remove if(u.getUnity()) i dont understand why the javascript not working.My object is Canvas and i attached script to it which has MyFunction and if this function worked i should see change in text.But cant see change.
I need help about this problem.I will be really happy with the solution.I dont really like javascript but i need to use it with communication it seems.
Your answer
Follow this Question
Related Questions
Clicking stops working when viewing WebPlayer games 0 Answers
Install unity web player from flash 2 Answers
Web Player Javascript Documentation 2 Answers
How o I prevent streamed video stutter? 1 Answer
Resize webplayer upon window resize 0 Answers