Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by lbender · May 14, 2014 at 12:18 AM · visualstudiotools

GetAllAssetPaths : System.Security.SecurityException

I'm trying to write a 3DS Max plugin that can read a unity scene. I am new to Unity C# development (and somewhat new to C# development too)

when I attempt to use AssetDatabase.GetAllAssetPaths() in my VS project, it crashes due to a security exception. I have all added references for the .dlls In C:\Program Files (x86)\Unity\Editor\Data\Managed to my VS project.

my super simple program to output the results of GetAllAssetPaths() to the console:

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using UnityEditor;
 namespace UnitySceneReader
 {
     class Program
     {
         static void Main(string[] args)
         {
             string[] assets=  AssetDatabase.GetAllAssetPaths();
             Console.Write(assets);
             Console.ReadLine();
         }
     }
 }

crashes with:

 An unhandled exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
 
 Additional information: ECall methods must be packaged into a system module.

can anybody clue me in on what I am doing wrong?

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

1 Reply

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

Answer by Jeff-Kesselman · May 14, 2014 at 12:36 AM

Um it looks like you are trying to use the Unity script environment OUTSIDE of Unity.

Why on earth would you imagine that this would work?

Comment
Add comment · Show 2 · 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 lbender · May 14, 2014 at 04:34 PM 1
Share

because I'm an optimistic noob, I figured I could reference unity's .dlls and be able to access its classes in my independant C# program. so these untiy editor classes won't work OUTSIDE of untiy. What exactly does it mean to code INSIDE of unity? How do I do that?

avatar image vexe · Jun 20, 2014 at 06:52 PM 0
Share

It means that what you're trying to do should be done from a script that lives in a Unity project. What if Unity was closed? what does GetAllAssetPaths mean in that case? how should it know how to react? What if there was more than one instance of Unity, etc.

You can reference Unity types from an external project yes, but you can't act on its editor/runtime API.

If you're unit-testing, you can mock things so you create fake GameObjects, etc but that's another subject.

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

21 People are following this question.

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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Script editors won't launch (at all) 1 Answer

Material doesn't have a color property '_Color' 4 Answers

VS2013 Attach to Unity does nothing 0 Answers

Any way to get Intellisense in Visual Studio 2010 to work with Unity? 1 Answer


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