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

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