Search Unity

Issue using "GUI-xxx" as a script name?

Discussion in 'Scripting' started by bigkahuna, Dec 7, 2007.

  1. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I've run into an issue and I'm wondering if it's due to a bug or my silliness:

    I've named a number of javascripts all beginning with "GUI-" (ie. "GUI-topmenu.js"). But when I try to reference a static variable in that script I get an error. If the script name starts with "GUI_" (ie. "GUI_topmenu.js"), I can reference the script without errors. Now it doesn't take a genius (lucky for me ;) ) to figure out how to fix this, but is this a bug or just how Javascript works?

    Thanks!
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Sorry if I'm misreading you, but have you used the minus sign as a hyphen? JS will interpret it as a minus operation between an object called GUI and another called topmenu if you do that.
     
  3. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Yup, that must be it. Just another bad habit I'll have to learn not to do any more. Thanks!
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    If there's a space or dash in the filename, I think when Unity converts that to a script name it will simply remove it. So the class in GUI-something probably has a classname of simply GUIsomething.