void Start() { canChangeItem = true; int count = listEnhanceItems.Count; dFactor = (Mathf.RoundToInt((1f / count) * 10000f)) * 0.0001f; mCenterIndex = count / 2; if (count % 2 == 0) { mCenterIndex = count / 2 - 1; } int index = 0; for (int i = count - 1; i >= 0; i--) { listEnhanceItems[i].CurveOffSetIndex = i; listEnhanceItems[i].CenterOffSet = dFactor * (mCenterIndex - index); listEnhanceItems[i].SetSelectState(false); GameObject obj = listEnhanceItems[i].gameObject; if (inputType == InputSystemType.NGUIAndWorldInput) { DragEnhanceView script = obj.GetComponent <DragEnhanceView>(); if (script != null) { script.SetScrollView(this); } } else { UDragEnhanceView script = obj.GetComponent <UDragEnhanceView>(); if (script != null) { script.SetScrollView(this); } } index++; } // set the center item with startCenterIndex if (startCenterIndex < 0 || startCenterIndex >= count) { Debug.LogError("## startCenterIndex < 0 || startCenterIndex >= listEnhanceItems.Count out of index ##"); startCenterIndex = mCenterIndex; } // sorted items listSortedItems = new List <EnhanceItem>(listEnhanceItems.ToArray()); totalHorizontalWidth = cellWidth * count; curCenterItem = listEnhanceItems[startCenterIndex]; curHorizontalValue = 0.5f - curCenterItem.CenterOffSet; LerpTweenToTarget(0f, curHorizontalValue, false); // // enable the drag actions // EnableDrag(true); }
public void initialize() { // Clear(); listSortedItems.Clear(); TextuerName = TextuerPropModel.GetInstance(); InstantiateTextuer(TextuerName.TEYP); canChangeItem = true; int count = listEnhanceItems.Count; dFactor = (Mathf.RoundToInt((1f / count) * 10000f)) * 0.0001f; mCenterIndex = count / 2; if (count % 2 == 0) { mCenterIndex = count / 2 - 1; } int index = 0; for (int i = count - 1; i >= 0; i--) { listEnhanceItems[i].CurveOffSetIndex = i; listEnhanceItems[i].CenterOffSet = dFactor * (mCenterIndex - index); //listEnhanceItems[i].SetSelectState(false); GameObject obj = listEnhanceItems[i].gameObject; if (inputType == InputSystemType.NGUIAndWorldInput) { DragEnhanceView script = obj.GetComponent <DragEnhanceView>(); if (script != null) { script.SetScrollView(this); } } else { UDragEnhanceView script = obj.GetComponent <UDragEnhanceView>(); if (script != null) { script.SetScrollView(this); } } index++; } // set the center item with startCenterIndex if (startCenterIndex < 0 || startCenterIndex >= count) { Debug.LogError("## startCenterIndex < 0 || startCenterIndex >= listEnhanceItems.Count out of index ##"); startCenterIndex = mCenterIndex; } // sorted items listSortedItems = new List <EnhanceItem>(listEnhanceItems.ToArray()); totalHorizontalWidth = cellWidth * count * cellWidthDeviant; curCenterItem = listEnhanceItems[startCenterIndex]; curHorizontalValue = 0.5f - curCenterItem.CenterOffSet; LerpTweenToTarget(0f, curHorizontalValue, false); // // enable the drag actions // EnableDrag(true); UITexture ME1 = Resources.Load <UITexture>("Prefabs/fuzi1"); //curCenterItem.GetComponent<UITexture>().mainTexture = Resources.Load<Texture>("Texture/centre" + curCenterItem.CurveOffSetIndex); fish1 = Instantiate(ME1, new Vector3(0, -1, 0), this.transform.rotation) as UITexture; fish1.mainTexture = Resources.Load <Texture>("song/" + TextuerName.listTextuerProp[curCenterItem.Number].textureSong); fish1.depth = 99; fish1.transform.parent = transform; fish1.transform.localScale = new Vector3(1, 1, 1); fish1.transform.localPosition = new Vector3(0, -1, 0); setAct(RS.getCurrentTextuer); setAct2(SO.GetComponent <StopOperation>().StopCallbackFunction); depthFactor = listEnhanceItems.Count; if (act != null) { act(curCenterItem.Number); } if (act2 != null) { act2(curCenterItem.Number); } SO.GetComponent <glrc>().chushihua(); }