public UIScrollBar scrollBar;
public float sliderValue, sliderSize;
public UIDraggablePanel dragPanel;
public GameObject springPanel;
SpringPanel spring;
public UICenterOnChild center;
public UIGrid grid;
void Start()
{
spring = (SpringPanel)springPanel.GetComponent<SpringPanel>();
Debug.Log ((spring != null));
}
public void Update()
{
sliderValue = scrollBar.scrollValue;
sliderSize = scrollBar.barSize;
if(sliderValue == 1 && sliderSize < 0.15) //check if we're all the way to the right
{
center.enabled = false; //Disable to try to get the closest object on re-enable
dragPanel.relativePositionOnReset = Vector2.zero;//position to beginning
dragPanel.ResetPosition();
spring
.target = new Vector3
(0,
78,
- 1);//try to spring.enabled = true;
center.enabled = true;
}
else if(sliderValue == 0 && sliderSize < 0.15)//check if we're all the way to the left
{
center.enabled = false;
dragPanel
.relativePositionOnReset = new Vector2
(1,
0);//position to end dragPanel.ResetPosition();
spring
.target = new Vector3
(-600,
78,
- 1); spring.enabled = true;
center.enabled = true;
}
}