comparing enum from a class in an editor script doesn't work

Hi,

Got a twisted problem, but hopefully solvable.

I am building a custom interface editor. In there, I want to display only the necessary fields, so I need to check values to know what to show and in which case. The problem is that the target value is an enum taken from a class in another script, and it doesn't let me do comparison with it.

in a script I have:

enum AxisList {xAxis,yAxis,zAxis}

class jf_pivotDrive {
/* 
I Use this class to hold the enum because I can't seem
to be able to access the enum from the reference of the component attached
to a RB 
*/
static var AxisList: AxisList;

}

in the script target ( linked to the editor)

public var whichAxis = jf_pivotDrive.AxisList.xAxis; 

and finally in the editor script

if ( target.whichAxis == jf_pivotDrive.AxisList.xAxis)

I get the following error:

The name 'jf_pivotDrive.AxisList' does not denote a valid type. Did you mean '.AxisList' ?

What should I do to have this work? should I define the class hoding the enum somewhere else without breaking other script using it? Is namespace should be involved if possible?

I know I could get away with this by simply using a string all the way instead of enum, but I am here to learn, and enum if a powerfull, trouble free feature and convenient gui component. Any advice or tips welcome.

thanks,

Jean

Enums are project-wide; don't try to refer to specific scripts. i.e., not jf_pivotDrive.AxisList, just AxisList. Although enums defined in editor scripts are not available in regular scripts (but vice versa is true...enums defined in regular scripts are available in editor scripts).

ok, Eric5h5 is right (thanks again) and it got rid of the error I mentionned.

Tho, it did not solved all my issues, so for the completness of the example given I post here what worked for me, yet I think it can be improved but I haven't found how.

if you use

 if ( target.whichAxis == AxisList.xAxis )

then it throws a new error

Operator '==' cannot be used with a left hand side of type 'System.Object' and a right hand side of type 'AxisList'.

and I could not cast it directly in the comparison line, so I used a temp variable for it and it works

 var temp: AxisList = target.whichAxis;
 if ( temp == AxisList.xAxis )

That works but I am sure it could be done in the same line for purist.

Jean