In Javascript, I have no problems getting scripts to talk to each other, but now I’ve got a function in a c# script, and I want it to call a function in a different Javascript, and I can’t, for the life of me figure out how to do it. No matter what I do, I keep getting “the type or namespace name “javascript script” could not be found…”
The very first thing you always need to do with this is read very carefully through the following document. It talks abou the sequence that unity follows when executing scripts.
You will also need to put one script type in standardasset
it is regarding compiling issue…
i forget what type to put in …
Try putting one type in the standard asset…
Try this, create a Plugins folder, put the c# script in that forlder, do not put the javascript in that folder or in the Standards Assets or Pro Standard Assets folder (put javascript in one of your own folders). See if this solves anything, if you have not tried that
You can’t put them both in the same folder. You need to put the javascript file in the “Standard Assets” or “Plugins” folder, and the C# file in a different folder without a special name.
Chubbspet has the right idea but backwards; you need to put the javascript (the one you want to call) in the Plugins folder to make sure it gets compiled first, and the C# (the one doing the calling) in a different folder to make sure it gets compiled second.
so it sounds like what I need it to do can’t be done. basically I have 4 scripts that need to be compiled in this order:
Javascript_A
C#_A and C#_B
Javascript_B
but if I put the J_A script in the pugins folder with C#_A and C#_B, C#_B breaks. if I put J_A in StandardAssets and the C# scripts in Plugins, C#_B breaks. If I put J_A in StandardAssets or Plugins and C# scripts anywhere else, J_B breaks.
not sure what else to do besides re-think my plans…
There are four steps you can use. So put JavaScript_A in “Standard Assets”, put C#_A and C#_B in “Standard Assets/Editor”, and then put Javascript_B in a normal folder.
Ah, you’re right, things in a “normal” folder can only access things from group 1 (Standard Assets, Plugins, etc). You could put Javascript_A in “Standard Assets”, the C# files in “Standard Assets/Editor” and Javascript_B into “Editor”, and that should work, but then JavaScript_B can’t access any other scripts in normal folders, which is probably an issue.
As that page says, the easier thing might be to rewrite Javascript_B to use dynamic types instead of named types. So don’t put DisplayTools.Test(), do something like GetComponent(“DisplayTools”).Test()… you can’t use the class name “DisplayTools” in javascript_b but you can get it by its string name as a “mystery” type.
UnityScript is compiled after C#, I believe. If you’re using C# scripts for everything, you can just toss them all into the same folder and any of them would still be able to access each other.
I tried all sorts of variations on GetComponent, and none of them seemed to work.
I’m basically trying to get the game to act on items that were purchased using Tapjoy’s virtual goods (using Prime31’s plugin). Since all of this happens in the main menu level, I’m just reloading the level if the player purchases something…seems to work okay so far…