반응형
offsetMin은 화면의 좌측 하단 기준, offsetMax는 화면의 우측 상단 기준으로 떨어진 값을 지정.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour {
RectTransform rt ;
public void RightSide() {
// 화면 밖 오른쪽에 붙이기
rt.offsetMin = new Vector2(Screen.width, 0f) ;
rt.offsetMax = new Vector2(Screen.width, 0f) ;
}
public void LeftSide() {
// 화면 밖 왼쪽에 붙이기
rt.offsetMin = new Vector2(Screen.width * -1, 0f) ;
rt.offsetMax = new Vector2(Screen.width * -1, 0f) ;
}
public void BottomSide() {
// 화면 밖 아래쪽에 붙이기
rt.offsetMin = new Vector2(0f, Screen.height * -1) ;
rt.offsetMax = new Vector2(0f, Screen.height * -1) ;
}
public void TopSide() {
// 화면 밖 위쪽에 붙이기
rt.offsetMin = new Vector2(0f, Screen.height) ;
rt.offsetMax = new Vector2(0f, Screen.height) ;
}
}
}
유니티 2D 애니메이션 : https://boxwitch.tistory.com/16
애드몹, 구글 플레이 서비스 유니티 플러그인 : https://boxwitch.tistory.com/29
유니티 포스트 프로세싱 적용 : https://boxwitch.tistory.com/64
DateTime을 string으로 : https://boxwitch.tistory.com/82
반응형
'tips > 자주쓰는 C# 스크립트' 카테고리의 다른 글
유니티 C# 자주쓰는 딕셔너리 Dictionary<T> 메서드들 (0) | 2021.02.04 |
---|---|
애드몹 적응형 배너 adaptive banner 적용하는 방법. (0) | 2021.01.23 |
유니티 C# Dictionary에서 Value로 Key 값 알아내기 (0) | 2020.12.24 |
유니티, Button 스크립트로 클릭 연결 onClick 이벤트 (2) | 2020.12.18 |
유니티, 일정한 시간 딜레이와 반복 Invoke (0) | 2020.12.18 |
댓글