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 /
  • Help Room /
This question was closed Nov 05, 2016 at 06:42 AM by eTavish for the following reason:

Solved this on my own

avatar image
0
Question by eTavish · Nov 03, 2016 at 02:17 PM · objectupdatescalescaling

Stuck with scaling an object

I've been trying to scale an object using its x,y,z axis using a slider. However, I have a problem trying to use 3 different sliders for each axis (x for length, y for width, and z for height). The problem is that only one slider works (which the only thing that scales is the height) in the code that I've done even though I've declared 3 sliders to perform a transform function for each axis. Can someone please tell me what's wrong and how to debug something like this? I've very new in unity. Thanks :)

Here's the code that I used on my sliders

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class ScaleSlider : MonoBehaviour {
 
     public Slider sliderLength;
     public Slider sliderWidth;
     public Slider sliderHeight;
 
     // Use this for initialization
     void Start () {
         sliderLength.value = 1;
         sliderWidth.value = 1;
         sliderHeight.value = 1;
 
     }
 
     // Update is called once per frame
     void Update () {
         transform.localScale = new Vector3 (sliderLength.value*1f, 1, 1);
         transform.localScale = new Vector3 (1, sliderWidth.value*1f, 1);
         transform.localScale = new Vector3 (1, 1, sliderHeight.value*1f);
     }
 }

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

  • Sort: 
avatar image
0

Answer by Cynikal · Nov 03, 2016 at 02:35 PM

 private float X = 0f;
 private float Y = 0f;
 private float Z = 0f;
 
 
 void Update()
 {
 X = sliderLength.value;
 Y = sliderWidth.value;
 Z = sliderHeight.value;
 
 transform.localScale = new Vector3(X, Y, Z);
 }
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

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Gradually editing the scale of an object 1 Answer

Scaling material without saving scale on original material 1 Answer

Scaling Challenge Help Needed! 0 Answers

2D Mobile GUI Scaler 1 Answer

Problem : Scale Object by distance 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