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 Shankar · May 07, 2013 at 01:17 PM · scalestretchmousedragscriping

How to stretch my scale in unity 3d ?

Hi All,

I think i had face some tricky situation in the unity 3d.

Actually my task is to stretch my scale to some point.

below is my scale look in the scene. if i drag a point to upwards i want my scale is stretch to upwards in the same scale.

alt text

the scale part is a maya game object with texturing.

For suppose if i drag a point to 3.4 in the y direction. than i want to show my scale is 4 times.with same texturing in y direction. in the same way x direction also.

please tell me a way how to do that task. i am little new to this type of tasks.

can i get a reference or else any coding help.

please help me

Thanks & Regards

Shankar

scale.png (6.6 kB)
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
1

Answer by robertbu · May 07, 2013 at 03:52 PM

One approach is to increase the tiling of the texture as the height of the object is increased:

 function Update () {
     renderer.material.mainTextureScale = Vector2(1.0, transform.localScale.y);
 }

I ran a quick test with a plane and a cylinder using your ruler above, and it worked. But if you've UV mapped the texture onto the 3D object it will not work.

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 Shankar · May 07, 2013 at 04:28 PM 0
Share

Thanks for answering $$anonymous$$r. Robertube,

really i didn't get your answer. I tired ur code but that not shown even my texture also.

In a scene i have this object and main camera. alt text

I want to write code, if i drag my mouse to upwards in a 4.5 points distance i want to show that object with 5 points height with proper texturing.

ruler is a object the place of the object is fixed. if i drag downwards i want to calculate the distance depended up on the distance i want to increase the length of the scale.

please help me.

Thanks you

shankar

ruler.png (38.2 kB)
avatar image robertbu · May 07, 2013 at 06:15 PM 0
Share

Your question as indicated in your followup information involves multiple technical questions 1)capturing mouse input 2) calculating vector3 positions in world coordinates based on mouse positions, 3) sizing and rotating object to fit between two Vector3s, etc. All of these have been answered multiple times on this list, and I'm not going to write the code for you. I suggest you tackle each one in turn, and if you get stuck, open a new question. The one piece of your problem I have not seen (and it may be there) was tiling the texture based on the height of the object. I wasn't sure how well it would work, but the results were surprising good. To reproduce my results, do the following:

  • Put the CreatePlane script in your Assets/Editor folder.

  • Create a vertical plane using the script. GameObject/Create Other/Custome Plane...

  • Set the X scale of the plane to .5 (just for looks).

  • Create a new material with an Unlit/Texture shader. Use the ruler in a vertical orientation as the texture. Apply the texture to the plane.

  • Put my code fragment above into a script and attach it to the plane.

  • Run the app. While running, select the plane in the hierarchy and adjust the Y scale.

This also worked with a cylinder (though obviously the ends of the cylinder get the texture as well which is problematic).

Here is the texture I used (clipped from your post):

alt text

ruler.png (4.3 kB)

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

13 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

Related Questions

Stretching a gameobject to fit viewport 4 Answers

Prevent the screen from stretching in different resolutions 0 Answers

How to stretch a scale 0 Answers

How will i drag my object only x and y axis? 2 Answers

how will my camera to move in the direction of dragging? 0 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