Why the object is not reduced in 2 times?

Why the object is not reduced in size in 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, everything works great.
And this script is attached to the light, but to the obj bound the cube
April 19th 20 at 12:18
1 answer
April 19th 20 at 12:20
Solution
So do not attach it to the light or what have you :)
Most likely is not invoked OnMouseDown
Well, just don't want a lot of these scripts create. What might not be called OnMouseDown? - xavier_Paucek commented on April 19th 20 at 12:23
I do not know. This divination will be. Maybe not EventSystems, maybe something else. I just do not use such methods, it is necessary to read docks. Certainly OnMouseDown to work he must to something, "stretch", to some object, or no Collider on the object or something. - deven_Sau commented on April 19th 20 at 12:26
@deven_Sau, well,thank you - xavier_Paucek commented on April 19th 20 at 12:29

Find more questions by tags Unity Game EngineC#