Esempio n. 1
0
 //向左翻页
 private void BtnleftVIP(GameObject go)
 {
     if (pageIndex.current != 1)
     {
         scrollView.MoveRelative(new Vector3(1000, 0, 0));
         centerOnChild.Recenter();
         pageIndex.InitPage(pageIndex.current, (int)VIPConsts.PAGEBOUNDARY_13);
     }
 }
Esempio n. 2
0
 void FixedUpdate()
 {
     if (Input.GetMouseButtonUp(0) && this.transform.childCount > 0)
     {
         centerOnChild.Recenter();
     }
 }
Esempio n. 3
0
    public void EnableAll()
    {
        Vector3 off = Vector3.right * offsetX;

        for (int i = 0; i < number; ++i)
        {
            Texture2D texture = LoadInsideUnity("TommyPlayground_" + i + ".png");
            if (texture != null)
            {
                if (list == null)
                {
                    list = new ArrayList();
                }
                list.Add(texturePrefab.Spawn(father.transform, texturePrefab.transform.position + off));
                off += Vector3.right * offsetX;
                ((UITexture)list[list.Count - 1]).gameObject.name      = i.ToString();
                ((UITexture)list[list.Count - 1]).mainTexture          = texture;
                ((UITexture)list[list.Count - 1]).transform.localScale = new Vector3(1, 1, 1);
                TouchPlantilla tPlan = ((UITexture)list [list.Count - 1]).GetComponent <TouchPlantilla> ();
                tPlan.NextButton = NextButton;
                tPlan.Manager    = father;
            }
        }
        backgroundSelected.AddFromOnCenter();
        father.enabled = true;
        father.Recenter();
    }
    static int Recenter(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        UICenterOnChild obj = (UICenterOnChild)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UICenterOnChild");

        obj.Recenter();
        return(0);
    }
Esempio n. 5
0
    public void ResetChildrenPosition()
    {
        Transform child = null;
        int       x = 0, y = 0;
        int       tempMaxPerLine = 0;

        for (int i = 0; i < TransChildCount; i++)
        {
            child = mChildren[i];
            if (child != null)
            {
                if (arrangement == Arrangement.Horizontal)
                {
                    tempMaxPerLine      = 0;
                    child.localPosition = new Vector3(cellWidth * x, -cellHeight * y, child.localPosition.z);
                }
                else if (arrangement == Arrangement.Vertical)
                {
                    tempMaxPerLine      = 0;
                    child.localPosition = new Vector3(cellWidth * y, -cellHeight * x, child.localPosition.z);
                }
                else if (arrangement == Arrangement.MatrixVertical)
                {
                    tempMaxPerLine      = maxPerLine;
                    child.localPosition = new Vector3(cellWidth * x, -cellHeight * y, child.localPosition.z);
                }
                else if (arrangement == Arrangement.MatrixHorizontal)
                {
                    tempMaxPerLine      = maxPerLine;
                    child.localPosition = new Vector3(cellWidth * y, -cellHeight * x, child.localPosition.z);
                }
            }
            if (++x >= tempMaxPerLine && tempMaxPerLine > 0)
            {
                x = 0;
                ++y;
            }
            child = null;
        }
        if (ScrollView != null)
        {
            ScrollView.contentPivot = pivot;
            if (arrangement == Arrangement.Horizontal || arrangement == Arrangement.MatrixHorizontal)
            {
                ScrollView.movement = UIScrollView.Movement.Horizontal;
            }
            else
            {
                ScrollView.movement = UIScrollView.Movement.Vertical;
            }
            ScrollView.ResetPosition();
        }
        if (isChildOnCenter && uiCenterOnChild != null && pivot != UIWidget.Pivot.Center)
        {
            uiCenterOnChild.Recenter();
        }
    }
Esempio n. 6
0
    void OnInitialize()
    {
        UIManager.Instance.CloseUI("TownHome");

        CameraController.Instance.MainCamera.gameObject.SetActive(false);

        if (mDrag == null)
        {
            mDrag = gameObject.GetComponentInChildren <UIDraggablePanel>();
        }

        ClearSkillList();

        FillSkillGrid();

        centerChild.onFinished = OnCenterCellChanged;

        _lastSelectedSkill = null;

        if (!_tutorialStarted)
        {
            TryStartTutorial();

            _tutorialStarted = true;
        }

        int skillNum = FindFirstNewSkill();

        if (skillNum >= 0)
        {
            SelectSkill(skillNum);
            _updateNewTagPosition = true;
        }
        else
        {
            SelectSkill(0);
            _updateNewTagPosition = false;
        }

        LevelManager.Singleton.StopActorMoving();

        centerChild.Recenter();
    }
Esempio n. 7
0
 static public int Recenter(IntPtr l)
 {
     try {
         UICenterOnChild self = (UICenterOnChild)checkSelf(l);
         self.Recenter();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 8
0
 static int Recenter(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UICenterOnChild obj = (UICenterOnChild)ToLua.CheckObject <UICenterOnChild>(L, 1);
         obj.Recenter();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
        public override void Start()
        {
            centerOnChild = scrollView.GetComponent <UICenterOnChild> ();

            var tap   = Instantiate(editor.getInstance.prefabs.NoteTapPrefab) as GameObject;
            var hold  = Instantiate(editor.getInstance.prefabs.NoteHoldPrefab) as GameObject;
            var swipe = Instantiate(editor.getInstance.prefabs.NoteSwipePrefab) as GameObject;

            AddBrush(tap);
            AddBrush(hold);
            AddBrush(swipe);

            centerOnChild.onCenter += OnBrushCenter;

            centerOnChild.Recenter();

            base.Start();
        }
Esempio n. 10
0
    /// <summary>
    /// Apply the dragging momentum.
    /// </summary>

    protected virtual void LateUpdate()
    {
        if (!Application.isPlaying)
        {
            return;
        }
        float delta = RealTime.deltaTime;

        // Fade the scroll bars if needed
        if (showScrollBars != ShowCondition.Always && (verticalScrollBar || horizontalScrollBar))
        {
            bool vertical   = false;
            bool horizontal = false;

            if (showScrollBars != ShowCondition.WhenDragging || mDragID != -10 || mMomentum.magnitude > 0.01f)
            {
                vertical   = shouldMoveVertically;
                horizontal = shouldMoveHorizontally;
            }

            if (verticalScrollBar)
            {
                float alpha = verticalScrollBar.alpha;
                alpha += vertical ? delta * 6f : -delta * 3f;
                alpha  = Mathf.Clamp01(alpha);
                if (verticalScrollBar.alpha != alpha)
                {
                    verticalScrollBar.alpha = alpha;
                }
            }

            if (horizontalScrollBar)
            {
                float alpha = horizontalScrollBar.alpha;
                alpha += horizontal ? delta * 6f : -delta * 3f;
                alpha  = Mathf.Clamp01(alpha);
                if (horizontalScrollBar.alpha != alpha)
                {
                    horizontalScrollBar.alpha = alpha;
                }
            }
        }

        if (!mShouldMove)
        {
            return;
        }

        // Apply momentum
        if (!mPressed)
        {
            if (mMomentum.magnitude > 0.0001f || mScroll != 0f)
            {
                if (movement == Movement.Horizontal)
                {
                    mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * 0.05f, 0f, 0f));
                }
                else if (movement == Movement.Vertical)
                {
                    mMomentum -= mTrans.TransformDirection(new Vector3(0f, mScroll * 0.05f, 0f));
                }
                else if (movement == Movement.Unrestricted)
                {
                    mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * 0.05f, mScroll * 0.05f, 0f));
                }
                else
                {
                    mMomentum -= mTrans.TransformDirection(new Vector3(
                                                               mScroll * customMovement.x * 0.05f,
                                                               mScroll * customMovement.y * 0.05f, 0f));
                }
                mScroll = NGUIMath.SpringLerp(mScroll, 0f, 20f, delta);

                // Move the scroll view
                Vector3 offset = NGUIMath.SpringDampen(ref mMomentum, 9f, delta);
                MoveAbsolute(offset);

                // Restrict the contents to be within the scroll view's bounds
                if (restrictWithinPanel && mPanel.clipping != UIDrawCall.Clipping.None)
                {
                    if (NGUITools.GetActive(centerOnChild))
                    {
                        centerOnChild.Recenter();
                    }
                    else
                    {
                        RestrictWithinBounds(false, canMoveHorizontally, canMoveVertically);
                    }
                }

                if (onMomentumMove != null)
                {
                    onMomentumMove();
                }
            }
            else
            {
                mScroll   = 0f;
                mMomentum = Vector3.zero;

                SpringPanel sp = GetComponent <SpringPanel>();
                if (sp != null && sp.enabled)
                {
                    return;
                }

                mShouldMove = false;
                if (onStoppedMoving != null)
                {
                    onStoppedMoving();
                }
            }
        }
        else
        {
            // Dampen the momentum
            mScroll = 0f;
            NGUIMath.SpringDampen(ref mMomentum, 9f, delta);
        }
    }
Esempio n. 11
0
 private void LateUpdate()
 {
     if (Application.isPlaying)
     {
         float deltaTime = RealTime.deltaTime;
         if (showScrollBars != 0 && ((bool)verticalScrollBar || (bool)horizontalScrollBar))
         {
             bool flag  = false;
             bool flag2 = false;
             if (showScrollBars != ShowCondition.WhenDragging || mDragID != -10 || mMomentum.magnitude > 0.01f)
             {
                 flag  = shouldMoveVertically;
                 flag2 = shouldMoveHorizontally;
             }
             if ((bool)verticalScrollBar)
             {
                 float alpha = verticalScrollBar.alpha;
                 alpha += ((!flag) ? ((0f - deltaTime) * 3f) : (deltaTime * 6f));
                 alpha  = Mathf.Clamp01(alpha);
                 if (verticalScrollBar.alpha != alpha)
                 {
                     verticalScrollBar.alpha = alpha;
                 }
             }
             if ((bool)horizontalScrollBar)
             {
                 float alpha2 = horizontalScrollBar.alpha;
                 alpha2 += ((!flag2) ? ((0f - deltaTime) * 3f) : (deltaTime * 6f));
                 alpha2  = Mathf.Clamp01(alpha2);
                 if (horizontalScrollBar.alpha != alpha2)
                 {
                     horizontalScrollBar.alpha = alpha2;
                 }
             }
         }
         if (mShouldMove)
         {
             if (!mPressed)
             {
                 if (mMomentum.magnitude > 0.0001f || mScroll != 0f)
                 {
                     if (movement == Movement.Horizontal)
                     {
                         mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * 0.05f, 0f, 0f));
                     }
                     else if (movement == Movement.Vertical)
                     {
                         mMomentum -= mTrans.TransformDirection(new Vector3(0f, mScroll * 0.05f, 0f));
                     }
                     else if (movement == Movement.Unrestricted)
                     {
                         mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * 0.05f, mScroll * 0.05f, 0f));
                     }
                     else
                     {
                         mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * customMovement.x * 0.05f, mScroll * customMovement.y * 0.05f, 0f));
                     }
                     mScroll = NGUIMath.SpringLerp(mScroll, 0f, 20f, deltaTime);
                     Vector3 absolute = NGUIMath.SpringDampen(ref mMomentum, 9f, deltaTime);
                     MoveAbsolute(absolute);
                     if (restrictWithinPanel && mPanel.clipping != 0)
                     {
                         if (NGUITools.GetActive(centerOnChild))
                         {
                             if (centerOnChild.nextPageThreshold != 0f)
                             {
                                 mMomentum = Vector3.zero;
                                 mScroll   = 0f;
                             }
                             else
                             {
                                 centerOnChild.Recenter();
                             }
                         }
                         else
                         {
                             RestrictWithinBounds(/*instant:*/ false, canMoveHorizontally, canMoveVertically);
                         }
                     }
                     if (onMomentumMove != null)
                     {
                         onMomentumMove();
                     }
                 }
                 else
                 {
                     mScroll   = 0f;
                     mMomentum = Vector3.zero;
                     SpringPanel component = GetComponent <SpringPanel>();
                     if (!(component != null) || !component.enabled)
                     {
                         mShouldMove = false;
                         if (onStoppedMoving != null)
                         {
                             onStoppedMoving();
                         }
                     }
                 }
             }
             else
             {
                 mScroll = 0f;
                 NGUIMath.SpringDampen(ref mMomentum, 9f, deltaTime);
             }
         }
     }
 }
Esempio n. 12
0
 public void Press(bool pressed)
 {
     if (UICamera.currentScheme == UICamera.ControlScheme.Controller)
     {
         return;
     }
     if (smoothDragStart && pressed)
     {
         mDragStarted     = false;
         mDragStartOffset = Vector2.zero;
     }
     if (!base.enabled || !NGUITools.GetActive(base.gameObject))
     {
         return;
     }
     if (!pressed && mDragID == UICamera.currentTouchID)
     {
         mDragID = -10;
     }
     mCalculatedBounds = false;
     mShouldMove       = shouldMove;
     if (!mShouldMove)
     {
         return;
     }
     mPressed = pressed;
     if (pressed)
     {
         mMomentum = Vector3.zero;
         mScroll   = 0f;
         DisableSpring();
         mLastPos = UICamera.lastWorldPosition;
         mPlane   = new Plane(mTrans.rotation * Vector3.back, mLastPos);
         Vector2 clipOffset = mPanel.clipOffset;
         clipOffset.x      = Mathf.Round(clipOffset.x);
         clipOffset.y      = Mathf.Round(clipOffset.y);
         mPanel.clipOffset = clipOffset;
         Vector3 localPosition = mTrans.localPosition;
         localPosition.x      = Mathf.Round(localPosition.x);
         localPosition.y      = Mathf.Round(localPosition.y);
         mTrans.localPosition = localPosition;
         if (!smoothDragStart)
         {
             mDragStarted     = true;
             mDragStartOffset = Vector2.zero;
             if (onDragStarted != null)
             {
                 onDragStarted();
             }
         }
     }
     else if ((bool)centerOnChild)
     {
         centerOnChild.Recenter();
     }
     else
     {
         if (restrictWithinPanel && mPanel.clipping != 0)
         {
             RestrictWithinBounds(dragEffect == DragEffect.None, canMoveHorizontally, canMoveVertically);
         }
         if (mDragStarted && onDragFinished != null)
         {
             onDragFinished();
         }
         if (!mShouldMove && onStoppedMoving != null)
         {
             onStoppedMoving();
         }
     }
 }
Esempio n. 13
0
    public void init(int num)
    {
        bool hidePage3, hidePage2, hidePage1;

        if (loaded == true)
        {
            return;
        }


        setMaxNum(num);
        pageList = new GameObject[3];

        //初始化3个页面


        if (transform.FindChild("001") != null && transform.FindChild("002") &&
            transform.FindChild("003") != null)
        {
            pageList [0] = transform.FindChild("001").gameObject;
            pageList [1] = transform.FindChild("002").gameObject;
            pageList [2] = transform.FindChild("003").gameObject;
        }
        else
        {
            for (int i = 0; i < 3; i++)
            {
                pageList [i]      = transform.GetChild(i).gameObject;
                pageList [i].name = "00" + (i + 1).ToString();
            }
        }



        hidePage2 = false;
        hidePage3 = false;
        hidePage1 = false;



        //如果不是无限页数
        if (num != -1)
        {
            if (maxPage < 3 && pageList [2].transform.localScale != Vector3.zero)
            {
                //	pageList [2].transform.localScale = new Vector3 (0.001f, 0.001f, 0.001f);
                //page3_locPosition = pageList [2].transform.localPosition;
                pageList [2].transform.localPosition = pageList [0].transform.localPosition + new Vector3(0, 3000, 0);
                pageList [2].name = "none";
                hidePage3         = true;
            }
            if (maxPage < 2 && pageList [1].transform.localScale != Vector3.zero)
            {
                //	pageList [1].transform.localScale = new Vector3 (0.001f, 0.001f, 0.001f);
                //page2_locPosition = pageList [1].transform.localPosition;
                pageList [1].transform.localPosition = pageList [0].transform.localPosition + new Vector3(0, 3000, 0);
                pageList [1].name = "none";
                hidePage2         = true;
            }
            if (maxPage < 1 && pageList [0].transform.localScale != Vector3.zero)
            {
                //	pageList [0].transform.localPosition = new Vector3 (0.001f, 0.001f, 0.001f);
                hidePage1         = true;
                pageList [0].name = "none";
            }
        }
        // check if need to reset
        if (hidePage3 == false)
        {
            pageList [2].transform.localScale = Vector3.one;

            //pageList[2].transform.localPosition = page3_locPosition;
        }
        else
        {
            pageList [2].transform.localScale = new Vector3(0.001f, 0.001f, 0.001f);
        }
        if (hidePage2 == false)
        {
            pageList [1].transform.localScale = Vector3.one;

            //pageList[1].transform.localPosition = page2_locPosition;
        }
        else
        {
            pageList [1].transform.localScale = new Vector3(0.001f, 0.001f, 0.001f);
        }
        if (hidePage1 == false)
        {
            pageList [0].transform.localScale = Vector3.one;
        }
        else
        {
            pageList [0].transform.localScale = new Vector3(0.001f, 0.001f, 0.001f);
        }



        _initAllButton();

        if (pageList [1] != null)
        {
            if (hidePage2 == false)
            {
                pageList [1].transform.localPosition = new Vector3(pageList [0].transform.localPosition.x + pageWidth, pageList [0].transform.localPosition.y, pageList [0].transform.localPosition.z);
                updateContent(pageList [1], 2);
            }
        }

        if (pageList [2] != null)
        {
            if (hidePage3 == false)
            {
                pageList [2].transform.localPosition = new Vector3(pageList [1].transform.localPosition.x + pageWidth, pageList [0].transform.localPosition.y, pageList [0].transform.localPosition.z);
                updateContent(pageList [2], 3);
            }
        }

        if (ScrollBar != null)
        {
            ScrollBar.Init(maxPage);
        }

        loaded = true;

        UICenter.Recenter();

        if (pageCount == 1)
        {
            updateContent(pageList [0], 1);
        }

        contentPanel.depth += 1;
    }