Author Topic: Javascript interaction  (Read 3151 times)

Legna

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Javascript interaction
« on: May 26, 2012, 05:03:20 AM »
Hello,

First, sorry for my ugly English. I'm French and really bad at grammar... OK word spelling also...

I tried to interact a javascript based project with NGUI. Searched for examples and tips but everything i found was not revelant enough for me to make it works.

I put all the folders in the plugin folder as intended, created a "test.js" file i put in a button object, then worked hard to get the "OnClick" information on this button or the change value of a slider.

I tried many ways, even by script reference :

  1. #pragma strict
  2. var _camera:UICamera;
  3.  
  4. function Onstart() {
  5.         _camera = Camera.main.GetComponent(UICamera);
  6. }
  7.  
  8. function Update() {
  9.         //test = _camera.OnHover;
  10.         test = _camera.OnHover();
  11.         // .. and many other tries...
  12. }
  13.  

And it did not even worked.

I tried also with accessing the UICamera function like with iTween, but no success also.

Does anyone got a working solution because all my google/board search where unsuccessfully.

Thanks for your help and your time !

Best Regards,

Alexandre.

Legna

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: Javascript interaction
« Reply #1 on: May 26, 2012, 05:35:39 AM »
ok... tested in NGUI example and finally

  1. function OnClick() {
  2.         print("click");
  3. }
  4.  

worked...

Now i have to find why it dont work in the tuto example i did... damn newbye of me...
« Last Edit: May 26, 2012, 05:42:09 AM by Legna »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Javascript interaction
« Reply #2 on: May 26, 2012, 11:16:14 AM »
Quote
function Onstart()
I think you mean Start, not Onstart.

Make sure "Raycast Hit Triggers" checkbox is checked in the physics properties and that your camera has UICamera attached.

Legna

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: Javascript interaction
« Reply #3 on: May 26, 2012, 03:21:54 PM »
Thanks for your answer. Yes i meant Start... too fast typing without thinking first...

I guess the mistake was coming effectively from the ray option.

Best regards,

Alexandre.