W
W
WeBBeW2020-04-16 13:16:19
C++ / C#
WeBBeW, 2020-04-16 13:16:19

Why is the object not reduced by 2 times?

Why is the object not reduced in size by 2 times?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    public GameObject obj;


    void Start()
    {

    }

    void OnMouseDown()
    {
        obj.transform.localScale = new Vector3(transform.localScale.x / 2f, 
            transform.localScale.y / 2f, transform.localScale.z / 2f);
    }
}


If you create another script for this object, then everything turns out.
And this script is attached to the light, but this cube is attached to obj

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mopsicus, 2020-04-16
@WeBBeW

Well, don't attach it to the light or whatever :)
Most likely, OnMouseDown is not called

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question