public void init(MyScrollViewElementDataList aDataList, Option aOption) { if (mOption != null) { return; } mOption = aOption; //オプション調整 if (mOption.infinitScrool) { mOption.sortable = false; //無限スクロールがonならソート機能は使えない } if (!mOption.sortable) { mOption.doubleTapSort = false; //ソート機能がoffならダブルタップでのソート機能もoff } if (!mOption.doubleTap) //ダブルタップがoff { mOption.doubleTapTime = 0; mOption.doubleTapSort = false; } //マスク gameObject.AddComponent <RectMask2D>(); RectTransform tRect = gameObject.GetComponent <RectTransform>(); tRect.sizeDelta = mOption.contentSize; tRect.pivot = new Vector2(0, 1); mDataList = aDataList; mState = new MyScrollViewWaitState(this); //可視部分collider MyBehaviour tColliderBehaviour = MyBehaviour.create <MyBehaviour>(); tColliderBehaviour.name = "myScrollViewContentCollider"; tColliderBehaviour.transform.parent = this.transform; tColliderBehaviour.position = new Vector3(0, 0, 0); tColliderBehaviour.scale = new Vector3(1, 1, 1); mCollider = tColliderBehaviour.gameObject.AddComponent <BoxCollider2D>(); mCollider.size = mOption.contentSize; mCollider.offset = new Vector2(mOption.contentSize.x / 2, -mOption.contentSize.y / 2); //表示領域 mContent = MyBehaviour.create <MyBehaviour>(); mContent.name = "myScrollViewContent"; mContent.transform.parent = this.gameObject.transform; mContent.position = new Vector3(0, 0, -0.1f); mContent.scale = new Vector3(1, 1, 1); //要素リスト mElements = new List <ElementTuple>(); initElements(); }
//状態遷移 private void changeState(MyScrollViewOperateState aState) { mState.exit(); mState = aState; mState.enter(); }