Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by NewfieJoe · May 21, 2011 at 10:44 PM · javascriptvector2exceptionrect

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by NewfieJoe · May 22, 2011 at 05:23 AM

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";
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Luke Briggs · May 21, 2011 at 11:16 PM

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! :)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Owen-Reynolds · May 22, 2011 at 02:44 AM 0
Share

Yeah...a quick access test is to break it out: int fff = blah.height; int ggg = blah.width; and see which one throws the error.

avatar image
0

Answer by Bunny83 · May 22, 2011 at 10:12 AM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NewfieJoe · May 22, 2011 at 05:34 PM 0
Share

The problem was the compile order. Since one private class was accessing the other private class I had to make $$anonymous$$enuSettings into a separate public class outside the outer class and place it in standard assets so it would compile before the outer class did. (The outer class was in assets/plugins) I thought they would be compiled in the order they appear and it actually seemed so, but at runtime it would throw up that error in the console. Just making it a public class inside the outer class would make the entry show up twice in the inspector IIRC.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

NullReferenceException help 1 Answer

ExecutionEngineException: SIGILL 0 Answers

Populating a Vector2 array in Javascript 1 Answer

Why doesn't Unity like my rectangles? 1 Answer

Vector2 AI help 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges