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 cj31387 · Sep 16, 2012 at 06:21 AM · prefabinspectorselect

Prefab can't select target Prefab

First of all I'm making a top down shooter, I have a mothership prefab which spawns a dropship prefab and in that dropship prefab there is a script transform.LookAt(target); My problem is in the prefab of the dropship. I try to set its target for the prefab for every dropship that will spawn by the mothership in the inspector which should be earth but it doesn't show any assets that are possible to select at all. I made earth a prefab, and this script works when I just put it on a dropship already in the scene (not as a prefab) it shows all kinds of assets it can target but not from within the prefab itself. How do I get the prefab to show earth in the prefab inspector?

alt text

selection.jpg (177.0 kB)
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 whydoidoit · Sep 16, 2012 at 10:59 AM

A prefab cannot target a scene object using the Inspector (this is logical because a prefab can be instantiated in any scene) - instead you need to assign the target during Awake or Start. You might have a string variable with the name of the game object to target and then use that to find the actual object when the prefab is instantiated.

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 save · Sep 16, 2012 at 11:34 AM 2
Share

In addition to $$anonymous$$ike's answer you could cache the transform at the very start. If earth has a script then you can do this:

 static var earthTransform : Transform;
 function Start () {
     earthTransform = transform;
 }

Then call it from outside the script:

 target = earthScript.earthTransform;
avatar image cj31387 · Sep 16, 2012 at 09:36 PM 0
Share

That worked. Thanks!

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

12 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

Related Questions

Jump back to Prefab in Project view when selected there 0 Answers

Prefab not loading in data from Inspector 1 Answer

Cannot draw default inspectors in custom EditorWindow 0 Answers

Is it possible to add a script to multiple objects seleced in the inspector? 1 Answer

if you've selected this enum. do this. How? 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