|
i have a c# script as my main script.. while clicking mouse i like to access a function from my another script created in java script......... is it possible if yes then how? thanks in advance
(comments are locked)
|
|
http://www.41post.com/1935/programming/unity3d-js-cs-or-cs-js-access ...The script you want to have access must be inside the "Standard Assets" or the "Plugins" folder. The other script has to be placed outside these folders. After this step, just call the GetComponent<...>() method as any other Component... @alberthci - thank u very much
Apr 13 '11 at 12:59 PM
ben
(comments are locked)
|
|
Scripts are class objects. Javascript files automatically inherit from MonoBehaviour unless otherwise declared, with the name of the file as the class name. So for example, if you have a script named GameController.js, you can create instances of it in your C# scripts like so:
You can then access any methods or properties just as you would with any other class. its not working
Mar 10 '11 at 07:11 PM
ben
in my scene have a button while button clicked nextScene = 1 activated if(nextScene == 1) {
Mar 10 '11 at 07:13 PM
ben
shows error as like follows, my .js name is ScriptName.js error CS0246: The type or namespace name `ScriptName' could not be found. Are you missing a using directive or an assembly reference?
Mar 10 '11 at 07:15 PM
ben
(comments are locked)
|
|
Are you just wanting to access the script directly, or call a function on a component. They are two different things, so careful how you word it. I'm not sure if you can GetComponent from C# to javascript because of how type-strong C# is. Have you tried a SendMessage? use SendMessage("functionname",argument); no i haven't tried send message............. ya i wanna access the whole script
Apr 05 '11 at 12:34 PM
ben
in that case you would try ScriptName script = GetComponent(); to get the script
Apr 06 '11 at 07:27 AM
Parthon
(comments are locked)
|
