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 TheBlip · Aug 10, 2013 at 12:55 AM · animationinstantiateprefab

Prefab and creating objects in script help

Okay I have a few questions about prefabs and creating duplicates in script. 1. I've made a prefab in the project tab, but does there have to be one instance of the prefab in the hierarchy? 2. How do I actually find the prefab in script? All the unity manual examples show duplication of the object that the script is in, but I want to duplicate on object that does not have the script in. 3. I'm supposing you set the prefab to a variable and then use Instantiate(avariable,Vector3,Quaternion.identity); Please correct me if I'm wrong. 4. My object has an animation that is set to play automatically. Will duplicating it reset the animation or will it also duplicate the time in the animation that it is at? In this case I'm just supposing that I'll have to change it to activate using script but I'd rather know ahead of time. Thanks for any answers, sorry if this is all too much for a single question, but I feel pretty straight forward about what I need to know at this point. Sorry if I'm missing any important information, I'm still new to scripting.

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
3
Best Answer

Answer by ArkaneX · Aug 10, 2013 at 10:04 AM

1) No.

2) You can load a prefab at runtime using Resources.Load or you can create a public field in your script, e.g.

 public Transform SomePrefab;

and using it in Instantiate method. To assign some prefab to it, click a script in project explorer, it will show in Inspector windows and you will notice "Some Prefab" on top of it. Drag any prefab from project explorer to it and that's all.

3) Yes, though you can use other overloads as well.

4) This I don't know, but should be very easy to check.

Complete description of steps required to instantiate prefab is available here: Instantiating prefabs.

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 TheBlip · Aug 10, 2013 at 02:10 PM 0
Share

Thanks a lot! Looks like I was mixing up Javascript with C# as well =/ But thanks for all the help it makes sense now.

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

15 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

Related Questions

How would i instantiate a prefab in the animation curve event? 1 Answer

Component on animated object while keeping the prefab 2 Answers

VUFORIA: Playing an animation for a instanced model? 2 Answers

Trying to assign GUIText from heirarchy into instantiated prefab 1 Answer

Can't move instantiated prefab 2 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