public static T Add <T>(this SimpleScrollSnap scroll, T panel, int index) where T : MonoBehaviour { if (scroll.NumberOfPanels != 0 && (index < 0 || index > scroll.NumberOfPanels)) { Debug.LogError( "<b>[SimpleScrollSnap]</b> Index must be an integer from 0 to " + scroll.NumberOfPanels + ".", scroll.gameObject); return(null); } panel = Object.Instantiate(panel, Vector2.zero, Quaternion.identity, scroll.Content); panel.transform.SetSiblingIndex(index); if (scroll.Validate()) { if (scroll.TargetPanel <= index) { scroll.startingPanel = scroll.TargetPanel; } else { scroll.startingPanel = scroll.TargetPanel + 1; } scroll.Setup(true); } return(panel); }
public void play() { SimpleScrollSnap menuScrollSnap = transform.Find("ScrollSnap").GetComponent <SimpleScrollSnap>(); Transform menuItemSelected = menuScrollSnap.Content.GetChild(menuScrollSnap.CurrentPanel); SpaceStation spaceStationSelected = menuItemSelected.GetComponent <MenuStationLevel>().spaceStation; SceneLoader.Instance.goToGame(spaceStationSelected.name); }
private void removeFromView(SimpleScrollSnap sss, int index) { //Pagination DestroyImmediate(sss.pagination.transform.GetChild(sss.NumberOfPanels - 1).gameObject); sss.pagination.transform.position += new Vector3(toggleWidth / 2f, 0, 0); //Panel sss.Remove(index); }
private void removeAllFromView(SimpleScrollSnap sss) { int panels = sss.NumberOfPanels - 1; for (int i = panels; i >= 0; i--) { removeFromView(sss, i); } }
private void AddToScrollView(string name, string Id, SimpleScrollSnap sss, GameObject toggle) { //Pagination Instantiate(toggle, sss.pagination.transform.position + new Vector3(toggleWidth * (sss.NumberOfPanels + 1), 0, 0), Quaternion.identity, sss.pagination.transform); sss.pagination.transform.position -= new Vector3(toggleWidth / 2f, 0, 0); //Panel var textObject = panel.GetComponentInChildren <TextMeshProUGUI>(); textObject.text = name; panel.GetComponent <Panel>().id = Id; sss.Add(panel, 0); }
void Start() { // ResetPlayer(); Debug.Log("ui"); LoadPlayer(); refresh.Invoke(); simpleScrollSnap = GetComponentInChildren <SimpleScrollSnap>(); Screen.fullScreen = false; screens = GetComponentsInChildren <UI_Screen>(true); if (m_StartScreen) { SwitchScreens(m_StartScreen); } if (m_Fader) { m_Fader.gameObject.SetActive(true); } //FadeOut(); FadeIn(); }