Unity3d -Javascript Examples?
Hi all, are there any examples of Noesis integrating with Javascript/Unityscript inside Unity3d?
I'm just trying to register a very simple button click in Unity button I am stumped at the start.
I'm getting the following error :BCE0164: Cannot infer generic arguments for method 'NoesisGUIPanel.GetRoot.<T>()'. Provide stronger type information through arguments, or explicitly state the generic arguments.
I get this error in the GetRoot command. Maybe I'm not using it right? It seems to be declared okay initially. Here's the code....
Thanks all!
Simon
I'm just trying to register a very simple button click in Unity button I am stumped at the start.
I'm getting the following error :BCE0164: Cannot infer generic arguments for method 'NoesisGUIPanel.GetRoot.<T>()'. Provide stronger type information through arguments, or explicitly state the generic arguments.
I get this error in the GetRoot command. Maybe I'm not using it right? It seems to be declared okay initially. Here's the code....
Code: Select all
//--------------------------Javascript---------------
var button01 : Noesis.Button;
var button02 : Noesis.Button;
var mainGUI : NoesisGUIPanel;
var grid : Noesis.Grid;
function Start () {
mainGUI = this.gameObject.GetComponent(NoesisGUIPanel);
grid = mainGUI.GetRoot();
}
//---------------------------
Simon
Re: Unity3d -Javascript Examples?
Hi,
This function takes a generic type. When i modify your code into the following :
the error disappears.
I'm not a javascript user though, so i don't know if it's a viable to use javascript with NoesisGUi on the long run.
This function takes a generic type. When i modify your code into the following :
Code: Select all
var button01 : Noesis.Button;
var button02 : Noesis.Button;
var mainGUI : NoesisGUIPanel;
var grid : Noesis.Grid;
function Start () {
mainGUI = this.gameObject.GetComponent(NoesisGUIPanel);
grid = mainGUI.GetRoot.<Noesis.Grid>();
}
I'm not a javascript user though, so i don't know if it's a viable to use javascript with NoesisGUi on the long run.
Re: Unity3d -Javascript Examples?
Cool thanks. Now my next step also gives me an error when I run the game...
InvalidCastException: Cannot cast from source type to destination type. I's clearly something to do with the button click function. I am trying to retrofit from the C# examples on the site.
Any ideas>
InvalidCastException: Cannot cast from source type to destination type. I's clearly something to do with the button click function. I am trying to retrofit from the C# examples on the site.
Any ideas>
Code: Select all
function Start () {
mainGUI = this.gameObject.GetComponent(NoesisGUIPanel);
grid = mainGUI.GetRoot.<Noesis.Grid>();
button01 = grid.FindName("Button01");
button01.Click+=Button1Clicked;
}
function Button1Clicked()
{
print("Button01 clicked!!!");
}
Re: Unity3d -Javascript Examples?
Using javascript with NoesisGUI is something we haven't yet investigated. Majority of users are using C#. Anyway the following code does what you want and it is working, I just tested it.
Code: Select all
#pragma strict
import Noesis;
var _btn : Button;
function Start ()
{
var gui = GetComponent.<NoesisGUIPanel>();
var root = gui.GetRoot.<FrameworkElement>();
_btn = root.FindName.<Button>("btn");
_btn.Click += OnBtnClick;
}
function OnBtnClick()
{
Debug.Log("Button clicked");
}
Re: Unity3d -Javascript Examples?
Cool, I got a slight variation on your code working fine. Hopefully JS will be supported/encouraged because there's a lot of users out there. Here's the code that works perfectly in Unity3d..
Code: Select all
var button01 : Noesis.Button;
var mainGUI : NoesisGUIPanel;
var grid : Noesis.Grid;
function Start () {
mainGUI = this.gameObject.GetComponent(NoesisGUIPanel);
grid = mainGUI.GetRoot.<Noesis.Grid>();
button01 = grid.FindName.<Noesis.Button>("Button01");
button01.Click+=Button1Clicked;
}
function Button1Clicked()
{
print("Button01 clicked!!!");
}
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests