Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Yorkim Parmentier · Mar 26, 2010 at 10:17 AM · editorcomponentaddcomponent

How to add a script to an imported object

Currently we are working on a project for our school.

I've added a few 3D models that where made by blender and 3DSMAX. But when I try to add script on it it doesn't doe anything. If I add the script on a cube (element of Unity) the script is working.

Is it possible to add a script to a model that was created outside Unity?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Digitalos · Jun 13, 2010 at 05:28 PM

You add scripts to meshes in much the same way as any other object and under the same conditions. There are a few things you could check:

1) Make sure the object is in your project view. 2) Try adding the script from the Component->Scripts menu as well as dragging it from the project. 3) If you are trying to construct a prefab using the mesh, it's certainly recommended to create a new GameObject in your scene, and then add the mesh object as a child under that. The reason for this is that later when you wish to manipulate the object or change it in any way, it doesn't interfere with the other components on the parent object, so you can easily swap visualisations in/out without messing anything up. Anyhow, it's worth trying this and adding the script directly to the parent and seeing if that is successful for you.

Comment
Add comment · 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
0

Answer by KvanteTore · Mar 26, 2010 at 10:33 AM

It is certainly possible, and adding scripts to an object with a custom mesh renderer or skinned mesh renderer should not be different from adding scripts to an object with one of the basic mesh renderers supplied with unity.

Could it be that you have not added the object to the scene, and that it is sitting in the project view? I strongly suggest you go through the tutorials to get a better understanding of how unity works.

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 Yorkim Parmentier · Mar 26, 2010 at 10:37 AM 0
Share

I'm sure that the object is in the scene. If I change the name of my function to Update the script runs.

avatar image KvanteTore · Mar 26, 2010 at 09:35 PM 1
Share

You have to name your method Update() for it to be run automatically every frame. If you call it FixedUpdate(), it will be called every fixed-update frame, that is every frame that advances the physics. For a complete list of methods that are called for various events, see the $$anonymous$$onoBehaviour documentation, http://unity3d.com/support/documentation/ScriptReference/$$anonymous$$onoBehaviour.html

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

Custom "Can't add due to conflicting component" 1 Answer

Create a Component Script for Editor Only 1 Answer

Unity doesn't store GUID field? 2 Answers

Why does the SceneGUI disappear when the component is folded? 0 Answers

Delete Component at Runtime 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