Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
3
Question by JaamiParvez · Mar 05, 2014 at 09:00 PM · objectscale

How can I scale my object in one direction???

Hey Everyone,

I've searched a lot but couldn't find what I want...

when I drag my mouse left for scaling my object but the object become wider from both sides and I only want it in on direction...

Is there any sample way to scale the object on one direction???

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

4 Replies

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

Answer by YourGamesBeOver · Mar 05, 2014 at 10:47 PM

Try this: make an empty GameObject, and add the one you want to scale as a child of it. move the inner object to position 0,0,0. then move the inner object such that the center of the parent object is at the edge of the inner object (in your case, the right edge). Now resize the outer GameObject as needed. Before you try to apply this, reset the scaling and position of your object, that should make this easier.

Comment
Add comment · Show 3 · 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 JaamiParvez · Mar 06, 2014 at 11:13 AM 0
Share

I made an empty object and added my object to the empty object but still no luck

avatar image JaamiParvez · Mar 06, 2014 at 12:38 PM 0
Share

finally did it Thanks :)

avatar image yuvaraj · Feb 23, 2019 at 09:49 AM 0
Share

This is the answer made by @YourGamesBeOver . But I broke them into steps and made few corrections.

  1. Create an empty game object and reset the position,scale

  2. $$anonymous$$ove the game object you would like to scale , such that the center of empty game object is at the edge of the game object you want scale.

  3. Now put this game object as the child of this empty game object. Now try to scale the empty game object, it would scale in one direction .

avatar image
2

Answer by thedetective456 · Dec 30, 2020 at 06:23 PM

Hi everyone!

For anyone wondering how to scale an object in a specific direction, this little function maybe helpful.

 public void Resize(float amount, Vector3 direction)
 {
      transform.position += direction * amount / 2; // Move the object in the direction of scaling, so that the corner on ther side stays in place
      transform.localScale += direction * amount; // Scale object in the specified direction
 }

Usage : If you want to scale a platform in z direction by 5 units, then

 Resize(5f, new Vector3(0f, 0f, 1f); // You can use Vector3.forward instead

That's it. Enjoy, Have a nice day!

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
1

Answer by Asle_Kinnerod · Mar 05, 2014 at 09:06 PM

You should change your pivot to FI "top-left". Depends on what kind of object, but normally pivot is set to center as default.

Comment
Add comment · Show 3 · 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 perchik · Mar 05, 2014 at 09:11 PM 0
Share

how do you change the pivot to top left?

avatar image Asle_Kinnerod · Mar 05, 2014 at 09:15 PM 0
Share

What kind of object are you working with? I´m not raven sure that you have the possibility on all kinds of objects.

avatar image JaamiParvez · Mar 06, 2014 at 11:07 AM 0
Share

Im working with a cube how can i change its pivot to left??

avatar image
0

Answer by scintilla0 · Jan 21 at 08:12 AM

If anyone needs to revert object to the old size here:

    void Update()
     {
         if (Input.GetMouseButtonDown(0))//LeftMouseButton
         {
             IncreaseObjectSize(5f, new Vector3(0f, 0f, 1f));
         }
         else if (Input.GetMouseButtonDown(1))//RightMouseButton
         {
             DecreaseObjectSize(5f, new Vector3(0f, 0f, 1f));
         }
     }
     public void IncreaseObjectSize(float amount, Vector3 direction)
     {
         transform.position += direction * amount / 2; // Move the object in the direction of scaling, so that the corner on ther side stays in place
         transform.localScale += direction * amount; // Scale object in the specified direction
     }
     public void DecreaseObjectSize(float amount, Vector3 direction)
     {
         transform.position -= direction * amount / 2;
         transform.localScale -= direction * amount;
     }


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

27 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 avatar image avatar image avatar image 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

How do I scale an object or prefab to a size in Unity units? 1 Answer

Object changes shape randomly. 1 Answer

Why won't my object grow? 1 Answer

Make gameobject a child without affecting scale? 1 Answer

How to make copy of object with 1,1,1 scale? 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