꿀먹는돼지
꿀돼지블로그
꿀먹는돼지
전체 방문자
오늘
어제
  • 분류 전체보기 (156)
    • 여행 (2)
    • TODAY (1)
    • 주식 (1)
    • DEV (58)
      • Server (2)
      • SpringFramework (5)
      • DB (0)
      • Unity (44)
      • 그냥 알고리즘공부 (2)
      • JAVA (2)
    • Aseprite (1)
    • OLD개발이야기 (63)
      • IT 공부 (6)
      • 알고리즘 공부 (6)
      • 개발관련 글 (3)
      • C++ (5)
      • C# (0)
      • Qt (8)
      • bigdata (2)
      • Python-mysql (12)
      • html (2)
      • python (1)
      • Android Studio (6)
      • 자바스크립트 (2)
      • 포트폴리오 (0)
      • 작업 (0)
      • 기타작업 (2)
    • IT Tools (1)
    • 기타 (12)

블로그 메뉴

  • 홈
  • 방명록
  • 태그
  • 미디어로그
  • 위치로그

공지사항

인기 글

태그

  • 도트
  • 유니티
  • honyepig
  • 1인개발
  • 육성게임
  • Unity
  • database
  • 위치캐슬
  • PYTHON
  • 도트게임
  • mysql
  • 모바일
  • 육성
  • 인디게임
  • 마녀
  • 게임
  • myql#외부접속
  • 마녀육성
  • 마녀 게임
  • 클리커

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
꿀먹는돼지

꿀돼지블로그

DEV/Unity

[solved] Unity Scroll View position initialize

2020. 12. 19. 23:40

Unity Scroll View Content position reset 

유니티에서 스크롤로 쭉 내린 후에, 다른 페이지 갔다가 다시 진입하면

그 위치 그대로 스크롤이 내려져 있다.

-> 맨 위 리스트를 보기 위해서 위치를 초기화 하려고 한다. 

 

한참 찾았는데 단순한 rect 위치 문제였다. 간단히 해결!

다들 헤매는 이유는

position 으로 접근한듯

anchoredPosition 임! 

1
2
3
4
5
6
7
8
    public RectTransform ScrollContent;
 
    public void setRectPosition() {
        float x = ScrollContents.anchoredPosition.x;
        ScrollContents.anchoredPosition = new Vector3(x, 0, 0);
   }
 
 
Colored by Color Scripter
c

 

 

Positioning the UI element

A UI Element is normally positioned using its Rect Transform. If the UI Element is a child of a Layout Group it will be automatically positioned and the positioning step can be skipped.

When positioning a Rect Transform it’s useful to first determine it has or should have any stretching behavior or not. Stretching behavior happens when the anchorMin and anchorMax properties are not identical.

For a non-stretching Rect Transform, the position is set most easily by setting the anchoredPosition and the sizeDelta properties. The anchoredPosition specifies the position of the pivot relative to the anchors. The sizeDelta is just the same as the size when there’s no stretching.

For a stretching Rect Transform, it can be simpler to set the position using the offsetMin and offsetMax properties. The offsetMin property specifies the corner of the lower left corner of the rect relative to the lower left anchor. The offsetMax property specifies the corner of the upper right corner of the rect relative to the upper right

 

'DEV > Unity' 카테고리의 다른 글

[solved] unity UI Text Color change separately 부분 색 바꾸기  (0) 2020.12.26
Unity Atlas 정리 및 이미지 최적화 정리  (2) 2020.12.22
Unity ads error Banner fail  (0) 2020.12.19
[solved] UnityWebRequest Get noneArray Type error  (0) 2020.12.19
NullReferenceException: Object reference not set to an instance of an objectUnityEditor.Graphs.Edge.WakeUp ()  (0) 2020.05.17
    'DEV/Unity' 카테고리의 다른 글
    • [solved] unity UI Text Color change separately 부분 색 바꾸기
    • Unity Atlas 정리 및 이미지 최적화 정리
    • Unity ads error Banner fail
    • [solved] UnityWebRequest Get noneArray Type error
    꿀먹는돼지
    꿀먹는돼지
    꿀꿀

    티스토리툴바