public void ScrollViewFirstArrange() { Transform previousCube = null; Transform parentScrollableView = null; Transform tScrollview = GameObject.Find("_ScrollView_").transform; if (tScrollview == null) { Debug.LogError("Please Add IPScrollView Prefabe in Scene"); return; } ipScrollController = tScrollview.GetComponent <IPScrollView> (); parentScrollableView = tScrollview.Find("_ScrollContent_"); foreach (Transform item in parentScrollableView.GetComponentsInChildren <Transform>()) { if (item != parentScrollableView) { Undo.DestroyObjectImmediate(item.gameObject); } } ipScrollController.scrollableObjects = new List <Transform> (); for (int i = 0; i < transformOfCubes.Count; i++) { Vector3 newPosition = Vector3.zero; if (i != 0) { newPosition = new Vector3(previousCube.localPosition.x + gapBetweenCubes, 0, 0); } previousCube = Instantiate(transformOfCubes [i], Vector3.zero, transformOfCubes [i].localRotation) as Transform; previousCube.name = IPScrollView.ButtonNamePrefix + (i).ToString(); ipScrollController.scrollableObjects.Add(previousCube); Undo.RegisterCreatedObjectUndo(previousCube.gameObject, "Created go"); previousCube.parent = parentScrollableView; previousCube.localPosition = newPosition; previousCube.localRotation = transformOfCubes [i].rotation; } RemoveColliderFrom(ipScrollController.scrollableObjects); AddBoxColliderTo(ipScrollController.scrollableObjects); }
// void OnEnable () // { // MySwipe.GestureTouchBegin += GestureTouchBegin; // MySwipe.GestureTouchMove += GestureTouchMove; // MySwipe.GestureTouchEnd += GestureTouchEnd; // } // // void OnDisable () // { // MySwipe.GestureTouchBegin -= GestureTouchBegin; // MySwipe.GestureTouchMove -= GestureTouchMove; // MySwipe.GestureTouchEnd -= GestureTouchEnd; // } void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this); } if (!PlayerPrefsX.GetBool(GameKeys.kprefBallFirstUnlock, false)) { PlayerPrefsX.SetBool(GameKeys.kprefBallFirstUnlock, true); int[] ballPrize = { 0, 50, 150, 200, 300, 400, 500, 600, 800, 1000 }; PlayerPrefsX.SetIntArray(GameKeys.kprefBallPrize, ballPrize); bool[] ballUnlock = { true, false, false, false, false, false, false, false, false, false }; PlayerPrefsX.SetBoolArray(GameKeys.kprefBallPrizeUnlock, ballUnlock); for (int i = 0; i < scrollableObjects.Count; i++) { if (ballUnlock [i]) { scrollableObjects [i].GetChild(0).GetChild(0).gameObject.SetActive(false); } else { scrollableObjects [i].GetChild(0).GetChild(0).GetComponent <TextMesh> ().text = ballPrize [i].ToString(); } } } // bool[] ballBool = PlayerPrefsX.GetBoolArray (GameKeys.kprefBallPrizeUnlock); // for(int i=1; i<ballBool.Length; i++) // { // if (ballBool [i] == true) // { // scrollview.GetChild (i).GetChild (0).GetChild(0).gameObject.SetActive (false); // } // } }
public void ChnageCubeGap() { Transform tScrollview = GameObject.Find("_ScrollView_").transform; if (tScrollview == null) { Debug.LogError("Please Add IPScrollView Prefabe in Scene"); } ipScrollController = tScrollview.GetComponent <IPScrollView> (); if (ipScrollController != null) { for (int i = 0; i < ipScrollController.scrollableObjects.Count; i++) { Vector3 newPosition = Vector3.zero; if (i != 0) { newPosition = new Vector3(ipScrollController.scrollableObjects [i - 1].localPosition.x + gapBetweenCubes, 0, 0); } ipScrollController.scrollableObjects [i].localPosition = newPosition; } } }