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
0
Question by thedodgeruk · Aug 18, 2012 at 11:42 PM · prefab

is there a way to make a script prefab?

i want to make a script prefab , so that i can add all the varaible and gameobject referneces i need to fill it all out , and the drag that onto a game object that needs it . i can do that with a gameobject , the drag the script on to it make it a prefab then fill it all in . but when i drag it to a model it add its to the gameobject heiracky and not the scrips , were i would like it to go , is there a way to do this ?

Comment
Add comment · Show 1
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 Khada · Aug 19, 2012 at 05:40 AM 1
Share

If someone answers your question, please mark it as answered. Your history shows that you consistently neglect to do this. I nearly answered your other question "collision collider game object", but wont be doing so unless you go through your old, answered questions and mark them correctly.

People time the time to help. The least you can do is give them their credit.

1 Reply

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

Answer by Khada · Aug 19, 2012 at 12:17 AM

Scripts can only exist as components on a game object (or inside other scripts / as static classes etc). However you can give your exposed variables a default value, though this doesn't really work with game object references:

 public float Foo = 1; //will be 1 by default in editor
 public GameObject Bar1 = null; //works
 public GameObject Bar2 = new GameObject(); //wont work
 public GameObject Bar3 = GameObject.Find("bla"); //wont work


numberkruncher: "If you select a script, the inspector allows you to specify default values (and associate other project wide objects) for new instances of script".

(credit to numberkruncher for the above quote)

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 numberkruncher · Aug 19, 2012 at 12:25 AM 1
Share

If you select a script, the inspector allows you to specify default values (and associate other project wide objects) for new instances of script. A useful trick that I stumbled upon a while back. $$anonymous$$ight be relevant, not sure...

avatar image Khada · Aug 19, 2012 at 12:31 AM 0
Share

Oh snap, you may be right. I remember seeing it but haven't used it like that before. I'll edit my answer.

avatar image thedodgeruk · Aug 19, 2012 at 05:23 PM 0
Share

thank you , just had a look at the inspector and being blunt i never noticed that and 99% chance i never would have , cheers

avatar image numberkruncher · Aug 19, 2012 at 05:32 PM 0
Share

I agree, it is definitely a little obscure. Another really useful factoid is the little lock icon at the upper-right of the inspector. It is SO useful!

avatar image Khada · Aug 20, 2012 at 07:04 AM 1
Share

Ah, the lock is awesome for when you want to keep a camera preview up and move things around :D

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

10 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

Related Questions

making prefabs at runtime? 2 Answers

Generated meshes/materials cannot be made into prefabs? 1 Answer

What is the name of/How do I use the box in the Script Inspector that allows you to assign values to Public data? 2 Answers

rot not working for 2nd prefab 2 Answers

Spawn a prefab 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