Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- // Locks width, but not height.
- [ExecuteInEditMode, RequireComponent(typeof(RectTransform))]
- public class RectTransormWidthLock : MonoBehaviour
- {
- private new RectTransform transform;
- [SerializeField] private float width = 1f;
- void Start()
- {
- this.transform = this.GetComponent<RectTransform>();
- }
- void Update()
- {
- this.transform.sizeDelta = new Vector2(width, this.transform.sizeDelta.y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement