So I hope the title makes sense.
Essentially what I am trying to do is have a draggable panel much like the one in the example except that when you get to the end it wraps to the beginning. It must center on the first (or last) object.
Currently I have my gui set up with a grid with 3 objects that center and it does wrap around. The problem is that it does not center on the first (or last) item and goes directly to the middle item.
Here is the script that I am currently using for this (C#)
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;
}
}
Any help would be greatly appreciated