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 Tim 1 · Nov 04, 2010 at 12:12 PM · javascriptprefabsimporting

Importing assets

Hi. I got stuck importing my spaceship to unity. I did import it but I cannot add javascript to it. Anyway, let me tell you exactly what I did and want to be done so you understand me better:

I created a spaceship in Maya for my spaceshooter game. I saved it in a map called SpaceshipMap along with the textures I created in photoshop. Also when I saved the spaceship in the SpaceshipMap there was also a map named .MayaSwatches. I don't know what its for but I suppose it doesn't matter. So I got this SpaceshipMap; in it, it is the maya file, 5 photoshop files, and the map named mayaswatches. I copy this whole map and paste it into my unity project assets folder. Then I got it in unity. In the projects part.

It is there as a map. I open the map and in there is another map where my UV mapping in maya is. Theres also a Spaceship Prefab and in that prefabs its all the objects I used to create my spaceship in maya. Then at last there is my 5 photoshop files, shown up as images.

Now my question is: How do I add a javascript to my Spaceship Prefab, so that I can drag it out in the scene (Hierarchy) later on and start to script in it?

Thanks in advance//Ticklebear

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

Answer by Ben 14 · Nov 04, 2010 at 04:20 PM

You can't add a component directly to a prefab in the project pane. Instead, instantiate the prefab in the scene (drag and drop it into the scene view), then add your scripts and components unto that scene object. Unity will tell you that you are losing the prefab connection, which is fine. Once you're satisfied with your setup, hit the Apply button in the inspector pane to update the original prefab with your new setup.

[edit, after checking] This won't work on mesh assets, however, because these are imported assets and not user-created prefabs, so you cannot modify them. In this case what I usually do is:

  1. create an empty gameobject in the scene
  2. add the mesh instance as a child of that gameobject
  3. equip the gameobject with the scripts and components you need
  4. create a new prefab in the project pane
  5. drag and drop your gameobject from the hierarchy pane unto the new prefab in the project pane

Hope this helps, Ben

Comment
Add comment · Show 5 · 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 DocSWAB · Nov 04, 2010 at 04:47 PM 0
Share

Here's the starting point for constructing game objects from models and scripts in a scene: http://unity3d.com/support/documentation/$$anonymous$$anual/Creating%20Scenes.html

Since it sounds like you're new to Unity, you can't go wrong by reading EVERYTHING in the manual and reference guide.

avatar image Ben 14 · Nov 04, 2010 at 06:46 PM 0
Share

$$anonymous$$y bad, there's no Apply on a modified mesh instance. AFAI$$anonymous$$, if you want to create an equiped prefab you've got to use an instance of the mesh as a child to another gameobject, which you may then "save" into a new prefab. Editing the answer...

avatar image Tim 1 · Nov 05, 2010 at 10:20 AM 0
Share

Thanks, thats something I think I will be able to do :P I was thinking of something similar to that, I tried it aswell but I didn't get long before I got stuck but I will follow you 1-5 list and hopefully I'll make it. Cheers

avatar image Tim 1 · Nov 05, 2010 at 12:40 PM 0
Share

One last thing, $$anonymous$$d explaining how to add a mesh instance as a child to my empty gameobject?

avatar image Ben 14 · Nov 08, 2010 at 06:26 PM 0
Share

Simply drag the mesh from the project pane over your gameobject name in the hierarchy view until it highlights the name. If you then release the mouse button, a new gameobject will be created with the mesh as a child of the parent object in the hierarchy.

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

No one has followed this question yet.

Related Questions

Building Block Prefabs 0 Answers

how do i attach GUITEXT to a prefab 1 Answer

Linking prefabs to classes that are not attatched to gameobjects 1 Answer

Accessing variable of instantiated prefab inside array in javascript 1 Answer

Need help understanding scripted prefab behavior - when I click one, the script runs on ALL prefab instances, not just the one I clicked. 3 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