Search Unity

Unity 5 - Cannot extend final type

Discussion in 'Scripting' started by JayG81, Jan 14, 2015.

  1. JayG81

    JayG81

    Joined:
    Sep 4, 2012
    Posts:
    72
    Since upgrading my project to Unity 5 I'm getting this error with JS.

    BCE0103: Cannot extend final type 'UnityEditor.Menu'.

    Here's my code for the class:

    Code (JavaScript):
    1. class Menu extends MonoBehaviour{
    2.  
    3. }
    And then extending that:

    Code (JavaScript):
    1. class MenuMain extends Menu{
    2.  
    3. }
    I'm not sure why this wouldn't work. Has worked since Unity 3 through 4.
     
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Is Menu an existing class in the UnityEditor namespace (ie. change your class names)
     
    angrypenguin and JayG81 like this.
  3. JayG81

    JayG81

    Joined:
    Sep 4, 2012
    Posts:
    72
    That just dawned on me now; it makes sense that the word "Menu" is probably used as a class. I'll change it up now and report back...
     
  4. JayG81

    JayG81

    Joined:
    Sep 4, 2012
    Posts:
    72
    Yup, that seems to be it. Now I have to deal with my class called "Audio"... I knew that one was going to come back to haunt me. :S
     
  5. BenZed

    BenZed

    Joined:
    May 29, 2014
    Posts:
    524
    Just put them in your own namespace. Then you can use all the duplicated names you like.

    EDIT: Just occured to me that you might not be able to do that in unityscript. Switch to C# :D
     
    User340 likes this.
  6. JayG81

    JayG81

    Joined:
    Sep 4, 2012
    Posts:
    72
    It actually only took me about 20 minutes to actually hunt the classes down and change them. Everything works great now with no errors. Took me 2 hours tops to upgrade the project from 4.x to 5.x. Not bad at all!
     
  7. BenZed

    BenZed

    Joined:
    May 29, 2014
    Posts:
    524

    OooOOoo. How's 5?
     
  8. JayG81

    JayG81

    Joined:
    Sep 4, 2012
    Posts:
    72
    I really haven't taken it for a proper test drive. Been working on another game in 4.6. A game portal site wanted a WebGL version of an old game, so I decided to upgrade it. The WebGL version doesn't work so well though. :(