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 benoit20 · Sep 26, 2012 at 09:12 PM · instantiatelocalscale

Issue with changing localScale of gameobject after instantiate

Hi,

I'm at a loss to figure out why modifying the local scale of an instantiated GameObject does not work immediately after instantiating. Best way to explain (PrefabManager contains lists to my prefabs, it's been thoroughly tested and has worked for months!):

This does not work, the scale changes are lost::

 myPrefabModel = (GameObject)GameObject.Instantiate(PrefabManager.theEquipmentModels["modelName"]);
 myPrefabModel.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);



This works:: (the method is called as a Coroutine)

 myPrefabModel = (GameObject)GameObject.Instantiate(PrefabManager.theEquipmentModels["modelName"]);
 yield return new WaitForSeconds(1.5f);
 myPrefabModel.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);

It seems I have to wait a very long time (1.5 secs minimum) in order to be allowed to alter the scale. I would much rather be able to do it immediately, it's not very pleasing aestethically!

Many thanks for the help to come,

Ben

Comment
Add comment · Show 4
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 hvilela · Sep 26, 2012 at 09:59 PM 0
Share

Can be that any script attached to you prefab changes the scale? So when you instantiate it with no delay one of your scripts change it back right after you, and when you delay it the script change it before you?

avatar image benoit20 · Sep 27, 2012 at 12:42 PM 0
Share

I see what you mean, but no. This prefab has no scripts attached to it. I was thinking of this being the cause but that's simply not possible, I have no other lines of code that alter the scale.

As it is I only need to alter scale because my models are not all on an equivalent scale, and i've got no time to redo all the animations ( Blender issue with rescaling, animations do not rescale and end up gibberish ).

avatar image whydoidoit · Sep 27, 2012 at 12:45 PM 0
Share

Well I can change the scale of my models directly after instantiation and have no problems - so this is not a restriction in Unity. Is something setting the parent of that transform perhaps - thereby making the scale have a different effect?

avatar image benoit20 · Sep 27, 2012 at 01:46 PM 0
Share

WhyDoIDoIt -- Hvilela, thanks for your prompt responses.

I went back and tested the only thing i hadn't changed -- which is the model. I came across another post of someone that had troubles with his blender model imports in regards to animations.

And hazaa. I removed the animations in the import wizard for this model and it has solved my troubles. Unity was most likely spinning a few cycles on some bad animation data from the blender file.

Thanks!

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by benoit20 · Sep 27, 2012 at 02:55 PM

For reference, the problem was due to the blender model, specifically animations in the model. Removing them in the import wizard solved the problem.

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

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

10 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

Related Questions

Checking if object intersects? 1 Answer

Instantiating and setting localScale doesn't work 1 Answer

Prefab color is black 1 Answer

How to make an object scale indefinately on key press? 3 Answers

Instantiating prefabs within the MeshFilter volume of object 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