Unity 4.6 beta button with Javascript rather than C#

I don’t know how much experience you guys have with the new beta. But i am in a bad position because all the new tutorials and explanations are in C#. I should probably learn it, but i would rather not at the moment. But the new gui button has an option to fire a public class. I dont really exactly know what it is because i use Javascript. But i tried making my function a static function, did not show up, a public function, it did not show up. Is there some sort of prefix i should put before the function. Because i just want it to fire a function from a different gameobject.

I have not messed with the new Beta but I know the new GUI is based on the NGUI which I do use and its buttons trigger a public void method inside of a class… (a function inside of a script). If you wish to continue using Javascript while using these buttons you could write a small C# script that just sends button calls along but it would be very inconvenient. Something like this.

// All scripts in C# and this stuff. 
using UnityEngin;
using System.Collection;

public Class ButtonExtention : Monobehaviour {
  /// Here is where the actual script is. where all the content goes. 
public GameObject JavascriptButtonReciver;

public void ButtonA{
 // Button A was pressed, Send it to the javascript
public void ButtonB{
 // Button B was pressed.


This would allow you to make as many public voids receivers as you want and then have the message relayed to your javascript as “BraodcastMessage” works the same in Javascript as it does in C# so you can broadcast messages from one to the other.

Forgive the errors as I am not near Unity to test the code. But you get the idea.

Well, you can do it the same way as in C#:

#pragma strict

import UnityEngine.EventSystems;

class Filth extends MonoBehaviour implements IPointerEnterHandler
	function OnPointerEnter(data : PointerEventData)
		Debug.Log(data.position.x+", "+data.position.y);

You can implement any of the events like that. You just need to explicitly declare a class and not lazily just fill a file with methods. But now you’re getting close to the verbosity of C# and still not getting faster compile times or namespaces :wink: