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
1
Question by deltamish · Jan 14, 2014 at 01:17 PM · dlllibrary

Acessing Scripts in Assets folder using .dll

Hi, I am creating a dll file for my AI engine.But i would love to acess other script as well

Is it possible to acess a script (say "Player Health Script" in Standard Assets Folder) from a dll project (which is inseide Unity Plugin folder)

if so would anyone be kind enough to guide me to do this

Thanks

Comment
Add comment · Show 7
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 ArkaneX · Jan 14, 2014 at 02:56 PM 0
Share

You should be able to do this using reflection, but I don't think it's a good solution. $$anonymous$$aybe you should use different approach ins$$anonymous$$d, e.g. events. Could you explain what is your goal?

avatar image deltamish · Jan 14, 2014 at 03:04 PM 0
Share

Hi @ArkaneX I have a dll file that has all functions and classes that i can acess from other script for building AI's with different behaviors

I would like to access the event system and object pooling script

The event system contains all the info about player and the AI's friends

But since these two are found in Assets folder i cant acess them using dll

avatar image ArkaneX · Jan 14, 2014 at 03:49 PM 1
Share

Is there a specific reason why you want to keep your project as a dll, and not as script files?

avatar image TonyLi · Jan 14, 2014 at 04:08 PM 1
Share

@Arkanex, for any medium to large project, loose script files aren't practical unless you have the patience of a saint. For example, load a reasonable battery of Asset Store code products into an empty project -- maybe Ultimate FPS, Scene $$anonymous$$anager, Sound $$anonymous$$anager Pro, AI Behaviours, cInput, and NGUI -- and see how long it takes to build. Not long in the grand scheme of the universe, I admit, but a real pain if you want to make tiny iterative changes to a single script and test them out quickly.

That said (and stepping off my soapbox :-) ), I totally agree with you that maybe a different solution would be better, such as providing an interface in the DLL that the DLL itself can reference, and writing implementations as loose scripts in Assets. Or even using Send$$anonymous$$essage() (itself a form of reflection) if it's not in a time-critical loop.

avatar image ArkaneX · Jan 14, 2014 at 04:18 PM 1
Share

Regarding dll vs project - if you want to quickly test tiny iterative changes, then script files is the way to go. You have to build anyway, and additionally you need to copy the output dll to the destination location. Of course you can automate this, but I still prefer to do it the scripts way :)

EDIT: there was a short info related to the Send$$anonymous$$essage which I deleted as soon as I saw what I posted. You can of course use it in this case.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by TonyLi · Jan 14, 2014 at 02:57 PM

Since the DLL is compiled without knowledge of the scripts in the Assets, you'll have to use reflection. Here's a good tutorial on using reflection.

Note that if you're building for iOS, you'll probably have to include a link.xml file so the scripts don't get stripped from the build.

Comment
Add comment · Show 6 · 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 deltamish · Jan 14, 2014 at 03:00 PM 0
Share

wow thanks for the reply I never knew that refletion could come in handy here

avatar image MrVerdoux · Jan 14, 2014 at 03:16 PM 0
Share

Excuse me if my opinion is absurd, but wouldn´t it be enough to add a reference to UnityEngine and then program normally?

avatar image MrVerdoux · Jan 14, 2014 at 03:59 PM 1
Share

Right, but you could add a reference to UnityEngine.dll and do unity stuff, as long as you don´t call any of your own scripts. Depending on your situation I´d image this could be enough. Using reflection seems more powereful but also a lot more dangerous!

avatar image ArkaneX · Jan 14, 2014 at 04:24 PM 1
Share

Even if he adds UnityEngine reference, he won't be able to see other script, because this dll won't even know about its existence.

avatar image MrVerdoux · Jan 14, 2014 at 04:28 PM 1
Share

Yes, but he can use transforms, rigidbodies, renderers, audio, cameras... $$anonymous$$ost useful compoenents are already built in so I thought it might be just enough.

Show more comments

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

OSC to Unity Messages 0 Answers

A node in a childnode? 1 Answer

Including a DLL in unity? 1 Answer

Cannot compile .exe with specific .dll. (but with other .dlls created the same way) 0 Answers

Obfuscating DLL classes from the users 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