What could be causing this problem reading from a Rect into a Vector2?

First time I’ve seen this error message:

FieldAccessException: Error verifying someScript:someFunction ():
Type at stack is not accessible at 0x00ea

Line that causes it:

v_MenuWindowSize = Vector2(screenPresets.Menu.Window.width, screenPresets.Menu.Window.height);

screenPresets.Menu.Window is a Rect.
screenPresets.Menu is a class container that has all of my variables for GUI layout for the screen.

It looks to me like you might be having an issue with permissions on the variable. If it’s in C# then it may need to start with public (e.g. public Rect Window=new Rect(…); ). You might also need to put static in there if it’s stored in another file to the one your trying to access it from:

C#: public static Rect Window=…

Js: static var Window:Rect=…

If not try storing a reference to the Rect before using it:

`
var theWindow:Rect=screenPresets.Menu.Window;

v_MenuWindowSize=Vector2(theWindow.width,theWindow.height);
`

Hope that helps! :slight_smile:

I have two variables referenced this way. .Presets worked fine before adding the MenuSettings class but because Preset can’t use .Menu for a variable declaration in this context it had to be moved into a separate script in Standard Assets\Scripts to be sure it was compiled first ( ScreenPresetList is in Plugins\ ).

public class ScreenPresetList {
  private class MenuSettings {
    public var Window: Rect;
    public var Buttons = new Rect[5];
    public var Music: Rect;
    public var FX: Rect;
    public var Skill: Rect;
    public var Label: String;
  } 
  private class Preset {
    public var Label: String;
    public var ScreenWidth: int;
    public var ScreenHeight: int;
    public var CameraOffset: float;
    public var MenuWindow: Rect;
    public var TinySkin: boolean;
    public var Menu: MenuSettings;
    public var ID: int;
    public var Skin: GUISkin;
  }
  public var ScreenPresetLabel: String;
  public var ScreenWidth: int;
  public var ScreenHeight: int;
  public var CameraOffset: float;
  public var Skin: GUISkin;
  public var Current: int;
  public var Menu: MenuSettings;
  public var Android = new Preset[12];
  public var iOS = new Preset[4];
  public var Browser = new Preset[3];
  public var Count: int = 12;
  public enum PlatformType { Android=0,
                              iPhone=1,
                                iPad=1,
                                  PC=2,
                           Macintosh=3,
                             Netbook=4,
                                 Web=5}
  public var Platform: PlatformType;
  private var fileName: String = "Game_Presets";
}

How about making your MenuSettings class public? A private class is only accessible from within the class so every variable of that type will throw an error if accessed outside the outer class.