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 TowerOfBricks · Jun 28, 2011 at 09:49 AM · plugincompiling

Compilation order, scripts in "Plugins" can't access full .Net

As simple as possible: In one script, i use System.IO.DirectoryInfo.GetFiles (string pattern). This works great, however if I place the script inside the Plugins folder (or actually Plugins/Editor instead of just Editor). I get a compiler error saying that DirectoryInfo doesn't have the function GetFiles. Really odd since the System.x classes shouldn't have to be compiled differently depending on where in the compilation order a script in Unity is, they should always be compiled first, shouldn't they?

Thanks

Comment
Add comment · Show 2
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 Graham-Dunnett ♦♦ · Jun 28, 2011 at 10:10 AM 0
Share

Not sure that the System.IO stuff is compiled at all - will be byte code in those things.

avatar image TowerOfBricks · Jun 28, 2011 at 01:32 PM 0
Share

The point is that it works when placed outside the Plugins folder. (in Editor/myscript ins$$anonymous$$d of Plugins/Editor/myscript). I'm not building anything, it's from the compilation for the editor I get the error. System.IO.File.ReadAllText doesn't seem to work either.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Aubrey-Falconer · Dec 22, 2011 at 06:53 PM

Sorry to answer such an old post - but Unity searches anywhere, any numbers of levels deep for editor folders - except in /Plugins or /Standard assets.

If you want to include editor scripts in Unity's first compilation pass, they must be placed inside /Assets/Plugins/Editor/.

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 Waz · Jun 28, 2011 at 01:18 PM

Are you building for WebPlayer? File access is not permitted there. It's a sandbox.

Comment
Add comment · Show 4 · 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 TowerOfBricks · Jun 28, 2011 at 01:32 PM 0
Share

Not building for anything, just inside the editor (see comment on my question).

avatar image Waz · Jun 28, 2011 at 03:06 PM 0
Share

Doesn't matter. If your build setting target is web player then chunks of API are not available, except to Editor/ files.

avatar image TowerOfBricks · Jun 28, 2011 at 03:23 PM 0
Share

Ok, what seems to be the problem is that my folder structure looks like Plugins/somefolder/Editor/myscript. And Unity doesn't seem to recognize the Editor folder scripts as Editor scripts. It works when the folder structure is Somefolder/Editor/myscript though, but perhaps Unity only searches two levels deep for editor folders. And I need to place the Somefolder folder there because I'm going to release this on the Asset Store, and they require that structure. The reason I need it in the Plugins folder in the first place is because the scripts need to able to be reached from Js.

avatar image TowerOfBricks · Jun 28, 2011 at 03:23 PM 0
Share

And you are correct, since my scripts weren't recognized as Editor scripts, they didn't have access to that API any more.

avatar image
0

Answer by demize2010 · Jun 28, 2011 at 01:40 PM

Seems like a weird error, could be to do with the compile order?

http://unity3d.com/support/documentation/ScriptReference/index.Script_compilation_28Advanced29.html

What happens if you put that function outside of Editor et al and call it with a SendMessage?

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 TowerOfBricks · Jun 28, 2011 at 01:42 PM 0
Share

Yes it has to do with compile order (look at the question name). And you cannot call that function with Send$$anonymous$$essage since it is not in another script, it is in a .Net class.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Recompiled plugins not refreshing in Unity 1 Answer

Can I get the Unity3D engine version in Xcode and how to do a conditional compile based on the version? 0 Answers

Speaker/earphone audio output toggle from unity c# script using "Lesser AudioSwitch" app 0 Answers

Google Admob error, Unable to resolve reference 'UnityEditor.iOS.Extensions.Xcode' 0 Answers

What is the general use of Awake(), Start(), Update(), FixedUpdate(), LateUpdate()? 7 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