Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How do I get a JS editor script to recognize a C# class? (They are in the proper folders)

Discussion in 'Scripting' started by infinitypbr, Mar 20, 2017.

  1. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    Googling sometimes helps. Sometimes, though, it only returns a lot of very popular answers that don't quite fit the bill :)

    I have a lot of C# classes, and I need to use a JS only function, Eval(), but unfortunately the JS file needs to access the classes. I have the files in the proper folders. However, I'm not sure how to ensure the JS file works with the class.

    Code (JavaScript):
    1. function RenameCategory(master : Master, code : String){
    2.         print ("Code To Run: " + code);
    3.         eval(code);
    4.     }
    That returns the error "The name 'Master' does not denote a valid type ('not found'). "

    Does anyone know what i need to do other than put them in the proper folders?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,738
    When you say "in the proper folders", what folders are those?

    What do you need eval for?
     
  3. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,071
    infinitypbr likes this.
  5. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Or put your C# script in a /Plugins folder which will make it compile earlier and your JS will be able to see it.
     
    infinitypbr likes this.
  6. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    Already done that -- however, I think doing the JS version isn't actually the better option.
     
    Dustin-Horne likes this.