- Home /
Button rect transform top
Hi, Im Beginner and I want to ask is it possible to change rect transform from 3rd script? So I have menager (as game object and script in it). This is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class maganer : MonoBehaviour {
//gracz1 = góra
//gracz2 = dół
public Button gracz1;
public Button gracz2;
void Start () {
Button btn1 = gracz1.GetComponent<Button>();
Button btn2 = gracz2.GetComponent<Button>();
btn1.onClick.AddListener(TaskOnClick);
btn2.onClick.AddListener(TaskOnClick2);
}
void TaskOnClick()
{
Debug.Log("gracz1 kliknął przycisk");
//rectTransform.sizeDelta = new Vector2(0, +5);
}
void TaskOnClick2()
{
Debug.Log("gracz2 kliknął przycisk");
}
}
I want to make Rect transform Top add 5 every click in both buttons. Can you help me?
Comment
Have you simply tried rectTransform.sizeDelta += new Vector2(0, 5);
Your answer
Follow this Question
Related Questions
UI button in Panel not clickable 2 Answers
Button position scaling weird 1 Answer
Delay Button Pressed Action after Animation 1 Answer
Rect transform position keeps changing value randomly 3 Answers