# mixing javascrit  C#

**URL:** https://discussions.unity.com/t/mixing-javascrit-c/413069
**Category:** C# & .NET
**Tags:** Scripting
**Created:** [May 4, 2010, 4:04pm UTC](https://discussions.unity.com/t/mixing-javascrit-c/413069 "2010-05-04T16:04:57Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![RickP](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@RickP](https://discussions.unity.com/u/RickP)
#### Post date: [May 4, 2010, 4:04pm UTC](https://discussions.unity.com/t/mixing-javascrit-c/413069/1 "2010-05-04T16:04:57Z")

</div>

Can we not mix the 2? The pathfinding library I’m using is in C#. It has a class named AIFollow. My scripts are in javascript, but when I try to make a variable of AIFollow I get "The name ‘AIFollow’ does not denote a valid type.

How can I hand this?

---

<div class="post-metadata">

### Author: ![Slem\_1](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/slem_1/32/393959_2.png) [@Slem\_1](https://discussions.unity.com/u/Slem_1)
#### Post date: [May 4, 2010, 5:21pm UTC](https://discussions.unity.com/t/mixing-javascrit-c/413069/2 "2010-05-04T17:21:26Z")

</div>

This has to do with the compile order. I think you might get it if you put the C# scripts in the Standard Assets folder.

Read this to get the full overview of the compile order:

> **[Unity - Scripting API:](https://docs.unity3d.com/ScriptReference/)**

---

<div class="post-metadata">

### Author: ![RickP](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@RickP](https://discussions.unity.com/u/RickP)
#### Post date: [May 4, 2010, 5:58pm UTC](https://discussions.unity.com/t/mixing-javascrit-c/413069/3 "2010-05-04T17:58:16Z")

</div>

Very cool. That seemed to work. Thanks!

---

<div class="post-metadata">

### Author: ![anon\_10321466](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@anon\_10321466](https://discussions.unity.com/u/anon_10321466)
#### Post date: [May 5, 2010, 9:21pm UTC](https://discussions.unity.com/t/mixing-javascrit-c/413069/4 "2010-05-05T21:21:26Z")

</div>

I’m also having difficulty accessing c# from within Javascript.

This is in a Javascript attached to the gameObject  
script = GetComponent(CubeRoller);  
script.whichway ();

CubeRoller is the c# script  
whichway() is the function in the c# script

the c# script is attached to the game object

but i get the message CubeRoller is an unknown identifier?

if the c# needs to be in the Standard Assets Folder, where should the Javascripts be put?

---

<div class="post-metadata">

### Author: ![anon\_77129249](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@anon\_77129249](https://discussions.unity.com/u/anon_77129249)
#### Post date: [May 5, 2010, 10:12pm UTC](https://discussions.unity.com/t/mixing-javascrit-c/413069/5 "2010-05-05T22:12:26Z")

</div>

as stated in the documention.

“All scripts that are compiled in this step have access to all scripts in the first group (“Standard Assets”, “Pro Standard Assets” or “Plugins”)”

So that’ means you’ probably want your javascript file in the root folder of the project.

---

<div class="post-metadata">

### Author: ![anon\_10321466](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@anon\_10321466](https://discussions.unity.com/u/anon_10321466)
#### Post date: [May 5, 2010, 10:16pm UTC](https://discussions.unity.com/t/mixing-javascrit-c/413069/6 "2010-05-05T22:16:15Z")

</div>

Ah Ha!!!

theres another way

// Calls the function ApplyDamage with a value of 5  
gameObject.SendMessage (“ApplyDamage”, 5);

// Every script attached to the game object  
// that has an ApplyDamage function will be called.  
function ApplyDamage (damage) {  
print (damage);  
}

this was also in the manual, and this time it works!!! :))
