2016-11-22 1 views
0

이전 게시글에서 저울 문제를 디버깅하는 방법에 대해 질문했습니다. Debugging Scale스케일의 크기 변경을 방지하려면 어떻게해야합니까?

문제를 해결 한 후에는 이해할 수없는 또 다른 문제가있는 것으로 보입니다. 내 버튼 목록을 삭제하고 새로운 버튼 목록 (새로 고침)을 채우려고합니다.

버튼을 삭제하고 다시 추가하는 기능이 생겼습니다. 원래 버튼을 설정하는 동일한 스크립트 인 MakeAllButtons을 사용하고 있습니다.

이는 내가 버튼의 목록을 제거하고이 보이는 버튼의 목록을 다시 추가 할 때 I 버튼을 enter image description here

의 목록을 채울 때 모습입니다. .3로 축소 축소. 내가 (단지 Add를 두 번 클릭) 버튼의 또 다른 목록을 추가하는 경우

enter image description here

그것은 다음과 같습니다 enter image description here

버튼의 목록 규모는 다시 가정 해가 될 수있는 위치에있다 .

ADD 버튼 코드 :

public void MakeAllButtons() 
    { 
     for (int i = 0; i < positionList.Count; i++) 
     { 

      Position position = positionList[i]; 
      PlayerPrefs.SetInt("PositionUnlocked" + i, position.unlocked); //sets if the item is unlocked 

      GameObject newButton = buttonObjectPool.GetObject(); 
      newButton.transform.SetParent(positionPanel, false); //this was the problem originally 

      ButtonDetails buttonDetails = newButton.GetComponent<ButtonDetails>(); 
      buttonDetails.SetupPosition(position, this); 
     } 
} 

제거 버튼 코드

public void RemoveButtons() 
{ 
    while (positionPanel.childCount > 0) 
    { 
     GameObject toRemove = positionPanel.transform.GetChild(0).gameObject; 
     buttonObjectPool.ReturnObject(toRemove); 
    } 
} 

newButton를 만든 후, 어떻게 든 newButton.localScale는 0.3로 설정하지만, 첫 번째 실행에 대한의를 통해되고있다 암호.

답변

0

개체를 제거하면 이전 로딩의 눈금이 저장되는 것으로 보입니다.

그래서 새로운 객체를 내가 원하는 스케일로 만들었고 문제가 수정되었습니다.

 GameObject newButton = buttonObjectPool.GetObject(); 
     newButton.transform.localScale = new Vector3(1, 1, 1); 
     newButton.transform.SetParent(positionPanel, false); 
관련 문제