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 cbzen · Dec 13, 2011 at 09:48 AM · fpspackagecompilation

Prevent a script from compiling ?

Hi, I would like to ship with my package(which already has several scripts) a new script. This script can only be used if the user has the Character Controller in the project. (The script tries to get the CharacterMotor component)

So if you import the package and the Character Controller is not in the project, you will get compilation errors. And my "clients" don't necessarily use the Character Controller.

Is there a way to prevent this script from compiling until it's actually used on an object ?

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 syclamoth · Dec 13, 2011 at 09:56 AM 0
Share

Well, you could short-circuit the whole thing by just including the Character$$anonymous$$otor script as a dependency of your script in the UnityPackage...

avatar image cbzen · Dec 13, 2011 at 10:52 AM 0
Share

Thank you. That would temporarily work, but when Unity updates the scripts it will be a mess to distinguish between my and their version.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Dreamora · Dec 13, 2011 at 10:46 AM

No, scripts in the project are always included. If you don't want them to be included, don't drop them into the project until you need them.

Its for code impossible to decide whats used and what not as you can use and create instances of classes from other classes not just cause they are on an object.

but generally code is no problem at least if it uses the unity engine only cause the engine is present anyway

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 cbzen · Dec 13, 2011 at 10:52 AM 0
Share

Thank you. I think I will simply create another package.

avatar image
0

Answer by Bunny83 · Dec 13, 2011 at 07:05 PM

Another way would be to rename your script (to *.txt for example) and than use an editor script which checks the project for the CharacterMotor class and automatically rename and reimport the script if needed. However this check have to be executed in some way after you've added the package to the project. An AssetPostProcessor is usually a good point to start with, but i guess it won't help when you import it together with the package (I guess it can't post process it's own package, at least not the first time).

Another problem is that you can't ship perfabs which use the script because you "removed" it from the package since you ship it as text-asset.

It's better to use seperate packages ;)

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 cbzen · Dec 13, 2011 at 07:53 PM 0
Share

I'm glad we agree :) Thank you for the brainstor$$anonymous$$g !

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

Exporting and keeping scripts 0 Answers

How to sprint and have a stamina bar? 0 Answers

Scores/points when you destroy something? 1 Answer

Attach a animation to 0 Answers

Editor Scripts in Dll 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