ForceUpdate() public method

Update the value of the scroll bar.
public ForceUpdate ( ) : void
return void
Exemplo n.º 1
0
        protected void CreateDialogChoices()
        {
            if (Conv.Continues)
            {
                float           offset    = 0.0f;
                float           fadeDelay = 0.05f;
                List <Exchange> RunningOutgoingChoices = Conv.RunningOutgoingChoices;
                List <GUIConversationBubble> choices   = new List <GUIConversationBubble> ();
                foreach (Exchange outgoingChoice in RunningOutgoingChoices)
                {
                    GameObject            newPlayerDialogChoiceGameObject = NGUITools.AddChild(PlayerDialogChoicesParent, PlayerDialogChoicePrototype);
                    GUIPlayerDialogChoice playerDialogChoice = newPlayerDialogChoiceGameObject.GetComponent <GUIPlayerDialogChoice> ();

                    playerDialogChoice.Choice = outgoingChoice;
                    playerDialogChoice.ChoiceButtonMessage.target       = gameObject;
                    playerDialogChoice.ChoiceButtonMessage.functionName = "MakeDialogChoice";
                    playerDialogChoice.gameObject.name = "Choice_" + outgoingChoice.Name;

                    GUIConversationBubble bubble = playerDialogChoice.GetComponent <GUIConversationBubble> ();
                    bubble.FadedColor          = (outgoingChoice.NumTimesChosen > 0);
                    bubble.FadeDelay           = fadeDelay;
                    bubble.EnableAutomatically = false;
                    playerDialogChoice.Offset  = offset;
                    bubble.SetProps(outgoingChoice.CleanPlayerDialog, Colors.Get.ConversationPlayerBackground, Colors.Get.ConversationPlayerOption);
                    offset    -= bubble.Height;
                    fadeDelay += 0.05f;
                    choices.Add(bubble);
                }
                PlayerDialogChoicesScrollbar.scrollValue = 0.0f;
                PlayerDialogChoicesScrollbar.ForceUpdate();
                StartCoroutine(WaitForDialogChoicesToBeReady(choices));
            }
        }
Exemplo n.º 2
0
 public void Update()
 {
     if (!Application.isPlaying)
     {
         return;
     }
     if (ResetPosition)
     {
         if (BackgroundSprite.transform.localScale.y > MaxScrollTargetSize)
         {
             //Debug.Log("Background sprite was larger than max scroll target size, so setting scroll to zero");
             //it's going to exceed the size of the panel
             TargetScrollbar.scrollValue = 0f;
         }
         else
         {
             //Debug.Log("Background sprite was smaller, setting scroll to target scroll");
             //move the object to 1/2 its height
             TargetScrollbar.scrollValue = ScrollTarget;
         }
         TargetScrollbar.ForceUpdate();
         ResetPosition = false;
     }
     enabled = false;
 }
Exemplo n.º 3
0
    /// <summary>
    /// Scroll bar template.
    /// </summary>

    void CreateScrollBar(GameObject go)
    {
        if (NGUISettings.atlas != null)
        {
            NGUIEditorTools.SpriteField("Background", "Sprite used for the background", NGUISettings.atlas, mScrollBG, OnScrollBG);
            NGUIEditorTools.SpriteField("Foreground", "Sprite used for the foreground (thumb)", NGUISettings.atlas, mScrollFG, OnScrollFG);

            GUILayout.BeginHorizontal();
            UIScrollBar.Direction dir = (UIScrollBar.Direction)EditorGUILayout.EnumPopup("Direction", mScrollDir, GUILayout.Width(200f));
            GUILayout.Space(20f);
            GUILayout.Label("Add colliders?", GUILayout.Width(90f));
            bool draggable = EditorGUILayout.Toggle(mScrollCL);
            GUILayout.EndHorizontal();

            if (mScrollCL != draggable || mScrollDir != dir)
            {
                mScrollCL  = draggable;
                mScrollDir = dir;
                Save();
            }
        }

        if (ShouldCreate(go, NGUISettings.atlas != null))
        {
            int depth = NGUITools.CalculateNextDepth(go);
            go      = NGUITools.AddChild(go);
            go.name = "Scroll Bar";

            UISprite bg = NGUITools.AddWidget <UISprite>(go);
            bg.type                 = UISprite.Type.Sliced;
            bg.name                 = "Background";
            bg.depth                = depth;
            bg.atlas                = NGUISettings.atlas;
            bg.spriteName           = mScrollBG;
            bg.transform.localScale = new Vector3(400f + bg.border.x + bg.border.z, 14f + bg.border.y + bg.border.w, 1f);
            bg.MakePixelPerfect();

            UISprite fg = NGUITools.AddWidget <UISprite>(go);
            fg.type       = UISprite.Type.Sliced;
            fg.name       = "Foreground";
            fg.atlas      = NGUISettings.atlas;
            fg.spriteName = mScrollFG;

            UIScrollBar sb = go.AddComponent <UIScrollBar>();
            sb.background  = bg;
            sb.foreground  = fg;
            sb.direction   = mScrollDir;
            sb.barSize     = 0.3f;
            sb.scrollValue = 0.3f;
            sb.ForceUpdate();

            if (mScrollCL)
            {
                NGUITools.AddWidgetCollider(bg.gameObject);
                NGUITools.AddWidgetCollider(fg.gameObject);
            }
            Selection.activeGameObject = go;
        }
    }
Exemplo n.º 4
0
    static int ForceUpdate(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        UIScrollBar obj = (UIScrollBar)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIScrollBar");

        obj.ForceUpdate();
        return(0);
    }
Exemplo n.º 5
0
 static public int ForceUpdate(IntPtr l)
 {
     try {
         UIScrollBar self = (UIScrollBar)checkSelf(l);
         self.ForceUpdate();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 6
0
 static int ForceUpdate(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UIScrollBar obj = (UIScrollBar)ToLua.CheckObject <UIScrollBar>(L, 1);
         obj.ForceUpdate();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 7
0
    private static int ForceUpdate(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 1);
            UIScrollBar uIScrollBar = (UIScrollBar)ToLua.CheckObject(L, 1, typeof(UIScrollBar));
            uIScrollBar.ForceUpdate();
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Exemplo n.º 8
0
    public static int ForceUpdate(IntPtr l)
    {
        int result;

        try
        {
            UIScrollBar uIScrollBar = (UIScrollBar)LuaObject.checkSelf(l);
            uIScrollBar.ForceUpdate();
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 9
0
    /// <summary>
    /// Scroll bar template.
    /// </summary>

    public static void CreateScrollBar(GameObject go)
    {
        if (ShouldCreate(go, NGUISettings.atlas != null))
        {
            int depth = 0;            //NGUITools.CalculateNextDepth(go);
            go      = NGUITools.AddChild(go);
            go.name = "Scroll Bar";

            UISprite bg = NGUITools.AddWidget <UISprite>(go);
            bg.type       = UISprite.Type.Sliced;
            bg.name       = "Background";
            bg.depth      = depth;
            bg.atlas      = NGUISettings.atlas;
            bg.spriteName = mScrollBG;

            Vector4 border = bg.border;
            bg.width  = Mathf.RoundToInt(400f + border.x + border.z);
            bg.height = Mathf.RoundToInt(14f + border.y + border.w);
            bg.MakePixelPerfect();

            UISprite fg = NGUITools.AddWidget <UISprite>(go);
            fg.type       = UISprite.Type.Sliced;
            fg.name       = "Foreground";
            fg.atlas      = NGUISettings.atlas;
            fg.spriteName = mScrollFG;

            UIScrollBar sb = go.AddComponent <UIScrollBar>();
            sb.foregroundWidget = fg;
            sb.backgroundWidget = bg;
            sb.fillDirection    = mFillDir;
            sb.barSize          = 0.3f;
            sb.value            = 0.3f;
            sb.ForceUpdate();

            if (mScrollCL)
            {
                NGUITools.AddWidgetCollider(bg.gameObject);
                NGUITools.AddWidgetCollider(fg.gameObject);
            }
            Selection.activeGameObject = go;
        }
    }
Exemplo n.º 10
0
    protected virtual void ResetScrolling(bool retainCurrentValue)
    {
        UIScrollBar bar  = null;
        UIScrollBar bar2 = null;

        if (this.myDraggablePanel != null)
        {
            if (!retainCurrentValue)
            {
                bar  = !this.vertical ? null : this.myDraggablePanel.verticalScrollBar;
                bar2 = !this.horizontal ? null : this.myDraggablePanel.horizontalScrollBar;
            }
            if (!this.didManualStart)
            {
                this.myDraggablePanel.ManualStart();
                this.didManualStart = true;
            }
            this.myDraggablePanel.calculateBoundsEveryChange = false;
            this.NextFrameRecalculateBounds();
        }
        else if (!retainCurrentValue)
        {
            bar  = (!this.vertical || this.horizontal) ? null : base.GetComponentInChildren <UIScrollBar>();
            bar2 = (!this.horizontal || this.vertical) ? null : base.GetComponentInChildren <UIScrollBar>();
        }
        if (!retainCurrentValue)
        {
            if (this.vertical && (bar != null))
            {
                bar.scrollValue = this.initialScrollValue.y;
                bar.ForceUpdate();
            }
            if (this.horizontal && (bar2 != null))
            {
                bar2.scrollValue = this.initialScrollValue.x;
                bar2.ForceUpdate();
            }
        }
    }
Exemplo n.º 11
0
        public void Update()
        {
            if (mEditObject == null)
            {
                return;
            }

                                                #if UNITY_EDITOR
            if (VRManager.VRMode | VRManager.VRTestingMode)
            {
                                                #else
            if (VRManager.VRMode)
            {
                                                #endif
                transform.localPosition = VRModeOffset;
            }
            else
            {
                transform.localPosition = NormalOffset;
            }

            SetChapterButtons();

            if (mUpdateDisplayNextFrame)
            {
                SetDisplayType();
                TryToDisplayChapter(mCurrentChapterNumber);
                CurrentScrollBar.scrollValue = 0f;
                mUpdateDisplayNextFrame      = false;
                mUpdateScrollbarNextFrame    = true;
            }

            if (mUpdateScrollbarNextFrame)
            {
                mUpdateScrollbarNextFrame    = false;
                CurrentScrollBar.scrollValue = 0f;
                CurrentScrollBar.ForceUpdate();
            }
        }
Exemplo n.º 12
0
    protected virtual void ResetScrolling(bool retainCurrentValue)
    {
        UIScrollBar componentInChildren;
        UIScrollBar uIScrollBar;
        UIScrollBar uIScrollBar1;
        UIScrollBar uIScrollBar2;
        UIScrollBar uIScrollBar3 = null;
        UIScrollBar uIScrollBar4 = null;

        if (this.myDraggablePanel)
        {
            if (!retainCurrentValue)
            {
                if (!this.vertical)
                {
                    uIScrollBar1 = null;
                }
                else
                {
                    uIScrollBar1 = this.myDraggablePanel.verticalScrollBar;
                }
                uIScrollBar3 = uIScrollBar1;
                if (!this.horizontal)
                {
                    uIScrollBar2 = null;
                }
                else
                {
                    uIScrollBar2 = this.myDraggablePanel.horizontalScrollBar;
                }
                uIScrollBar4 = uIScrollBar2;
            }
            if (!this.didManualStart)
            {
                this.myDraggablePanel.ManualStart();
                this.didManualStart = true;
            }
            this.myDraggablePanel.calculateBoundsEveryChange = false;
            this.NextFrameRecalculateBounds();
        }
        else if (!retainCurrentValue)
        {
            if (!this.vertical || this.horizontal)
            {
                componentInChildren = null;
            }
            else
            {
                componentInChildren = base.GetComponentInChildren <UIScrollBar>();
            }
            uIScrollBar3 = componentInChildren;
            if (!this.horizontal || this.vertical)
            {
                uIScrollBar = null;
            }
            else
            {
                uIScrollBar = base.GetComponentInChildren <UIScrollBar>();
            }
            uIScrollBar4 = uIScrollBar;
        }
        if (!retainCurrentValue)
        {
            if (this.vertical && uIScrollBar3)
            {
                uIScrollBar3.scrollValue = this.initialScrollValue.y;
                uIScrollBar3.ForceUpdate();
            }
            if (this.horizontal && uIScrollBar4)
            {
                uIScrollBar4.scrollValue = this.initialScrollValue.x;
                uIScrollBar4.ForceUpdate();
            }
        }
    }
        private void Update()
        {
            if (!m_isInstall || m_child == null)
            {
                // 子供が作られ終わったら
                if (transform.childCount > 0)
                {
                    UIGrid grid = transform.GetComponent <UIGrid>();

                    if (grid)
                    {
                        // 子供(ボタン)を取得
                        List <Transform> items          = grid.GetChildList();
                        float            topY           = float.MinValue;
                        Transform        topButton      = null;
                        Transform        selectedButton = null;

                        // フレームに拡縮アニメーション用のコンポーネントを付けていく
                        foreach (var item in items)
                        {
                            Transform frame = item.Find("Frame");

                            if (frame)
                            {
                                // コンポーネントを付ける
                                frame.gameObject.AddComponent <SelectedAnime>();

                                // フレームがアクティブなら選択されたボタン
                                if (frame.gameObject.activeSelf)
                                {
                                    selectedButton = frame.parent;
                                }
                                // 一番上の列にあるボタンを探しておく
                                // 上のほうがローカルYが大きい
                                if (frame.parent.localPosition.y > topY)
                                {
                                    topY      = frame.parent.localPosition.y;
                                    topButton = frame.parent;
                                }

                                m_child = item.gameObject;
                            }
                        }

                        // 選択されたボタンをまでスクロールするかどうか
                        if (Define.AutoScrollEnable)
                        {
                            if (selectedButton && topButton)
                            {
                                UICenterOnChild coc = GetComponent <UICenterOnChild>();
                                UIScrollView    sv  = transform.parent.GetComponent <UIScrollView>();
                                UIScrollBar     sb  = transform.parent.parent.GetComponentInChildren <UIScrollBar>();

                                if (coc && sv && sb)
                                {
                                    // スクロールバーが有効なら
                                    if (sv.shouldMoveVertically)
                                    {
                                        // ローカル位置にボタンの座標が入っている
                                        float buttonPos = Math.Abs(selectedButton.localPosition.y - topButton.localPosition.y);
                                        // 一番下まで下げた時のビューの位置
                                        float bottomPos = sv.bounds.size.y - sv.panel.height + 20;
                                        // スクロールバーの位置
                                        float scrollVal = 0.0f;

                                        // バーの位置を算出する
                                        scrollVal = buttonPos / bottomPos;
                                        scrollVal = Math.Max(Math.Min(scrollVal, 1.0f), 0.0f);

                                        sb.value = scrollVal;
                                        sb.ForceUpdate();
                                    }
                                }
                            }
                        }

                        m_isInstall = true;
                    }
                }
            }
        }