Skip to main content
retagged with correct scripting tag; cleaned up question
Source Link
user3071284
  • 7.1k
  • 6
  • 46
  • 60

Unity3d javascript script UnityScript "does not exist"

I tried to add one of my scripts to a unity3dUnity project., but Unity claims that it does not exist. Now none of my Scriptsscripts are working. I tried looking on the web, but apparently I'm the only person who uses Javascript in UnityUnityScript. 

Here's the doorScript that started this problem.:

#pragma strict   // SmothlySmoothly open a door var smooth = 2.0; private var open : boolean; private var enter : boolean; var say : String; private var defaultRot : Vector3; var openRot : Vector3; function Start(){ defaultRot = transform.eulerAngles; } //Main function function Update (){ if(open){ //Open door transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, openRot, Time.deltaTime * smooth); } else{ //Close door transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, defaultRot, Time.deltaTime * smooth); } if(Input.GetKeyDown("e") && enter){ open = !open; } } function OnGUI(){ if(enter){ GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 150, 30), say); } } //Activate the Main function when player is near the door function OnTriggerEnter (other : Collider){ if (other.gameObject.tag == "Player") { enter = true; } } //Deactivate the Main function when player is go away from door function OnTriggerExit (other : Collider){ if (other.gameObject.tag == "Player") { enter = false; } } 

The file is named doorScript.js  . itIt worked on my last project so if you want to take it go ahead but it won't work on my FPS project.

Unity3d javascript script "does not exist"

I tried to add one of my scripts to a unity3d project. but Unity claims that it does not exist. Now none of my Scripts are working. I tried looking on the web but apparently I'm the only person who uses Javascript in Unity. Here's the doorScript that started this problem.

#pragma strict   // Smothly open a door var smooth = 2.0; private var open : boolean; private var enter : boolean; var say : String; private var defaultRot : Vector3; var openRot : Vector3; function Start(){ defaultRot = transform.eulerAngles; } //Main function function Update (){ if(open){ //Open door transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, openRot, Time.deltaTime * smooth); } else{ //Close door transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, defaultRot, Time.deltaTime * smooth); } if(Input.GetKeyDown("e") && enter){ open = !open; } } function OnGUI(){ if(enter){ GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 150, 30), say); } } //Activate the Main function when player is near the door function OnTriggerEnter (other : Collider){ if (other.gameObject.tag == "Player") { enter = true; } } //Deactivate the Main function when player is go away from door function OnTriggerExit (other : Collider){ if (other.gameObject.tag == "Player") { enter = false; } } 

The file is named doorScript.js  . it worked on my last project so if you want to take it go ahead but it won't work on my FPS project.

UnityScript "does not exist"

I tried to add one of my scripts to a Unity project, but Unity claims that it does not exist. Now none of my scripts are working. I tried looking on the web, but apparently I'm the only person who uses UnityScript. 

Here's the doorScript that started this problem:

#pragma strict // Smoothly open a door var smooth = 2.0; private var open : boolean; private var enter : boolean; var say : String; private var defaultRot : Vector3; var openRot : Vector3; function Start(){ defaultRot = transform.eulerAngles; } //Main function function Update (){ if(open){ //Open door transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, openRot, Time.deltaTime * smooth); } else{ //Close door transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, defaultRot, Time.deltaTime * smooth); } if(Input.GetKeyDown("e") && enter){ open = !open; } } function OnGUI(){ if(enter){ GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 150, 30), say); } } //Activate the Main function when player is near the door function OnTriggerEnter (other : Collider){ if (other.gameObject.tag == "Player") { enter = true; } } //Deactivate the Main function when player is go away from door function OnTriggerExit (other : Collider){ if (other.gameObject.tag == "Player") { enter = false; } } 

The file is named doorScript.js. It worked on my last project so if you want to take it go ahead but it won't work on my FPS project.

Source Link

Unity3d javascript script "does not exist"

I tried to add one of my scripts to a unity3d project. but Unity claims that it does not exist. Now none of my Scripts are working. I tried looking on the web but apparently I'm the only person who uses Javascript in Unity. Here's the doorScript that started this problem.

#pragma strict // Smothly open a door var smooth = 2.0; private var open : boolean; private var enter : boolean; var say : String; private var defaultRot : Vector3; var openRot : Vector3; function Start(){ defaultRot = transform.eulerAngles; } //Main function function Update (){ if(open){ //Open door transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, openRot, Time.deltaTime * smooth); } else{ //Close door transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, defaultRot, Time.deltaTime * smooth); } if(Input.GetKeyDown("e") && enter){ open = !open; } } function OnGUI(){ if(enter){ GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 150, 30), say); } } //Activate the Main function when player is near the door function OnTriggerEnter (other : Collider){ if (other.gameObject.tag == "Player") { enter = true; } } //Deactivate the Main function when player is go away from door function OnTriggerExit (other : Collider){ if (other.gameObject.tag == "Player") { enter = false; } } 

The file is named doorScript.js . it worked on my last project so if you want to take it go ahead but it won't work on my FPS project.