- Home /
Calling a c# script from js [for NGUI]
I'm attempting to update an NGUI UILabel with my playerHeath.
The health script is written in java and so I was trying to reference my c# script that updates the health on the user-interface.
function OnCollisionEnter (myCollision : Collision)
{
if (myCollision.gameObject.tag == "enemy")
{
ApplyDamage(10);
var healthUpdate: HealthUpdate = GetComponent(HealthUpdate);
healthUpdate.Start();
}
}
I'm receiving The name 'HealthUpdate' does not denote a valid type ('not found').
Answer by Jeff-Kesselman · Apr 29, 2014 at 09:31 PM
First off ,its not written in Java. Unity does not support Java.
It might be written in Javascript which is something totally different. Don't confuse the languages.
Secondly, in order to call a C# script from Javascript it must be in a folder whose compile order is before the folder the Javascript code is in.
See this article for compile order.
https://docs.unity3d.com/Documentation/Manual/ScriptCompileOrderFolders.html
Your answer

Follow this Question
Related Questions
Public Health Var C# 1 Answer
Health script 0 Answers
Trying to get 2 floats synced up. 2 Answers
Semicircular Health/Mana/Progress Bars 0 Answers
Heart rate Bluetooth PLUGIN IOS 0 Answers