Esempio n. 1
0
    void Start()
    {
        UnityEngine.Object.DontDestroyOnLoad(this);
        uiText = GameObject.FindGameObjectWithTag("TracesLog");
        tracesLog = uiText.GetComponent<UnityEngine.UI.Text>();

        GameObject scrollImg = GameObject.Find("ScrollImage");
        scroll = scrollImg.GetComponent<UnityEngine.UI.ScrollRect>();

        rectT = uiText.GetComponent<RectTransform>();
        Debug.Log(tracesLog.text);
        tmpSize = new Vector2(0, 0);
        iReallyNeedToPutItOnZero = false;
    }
 public static void LateUpdate_Pre(UnityEngine.UI.ScrollRect __instance)
 {
     if (state != null && state.inventoryWidget.scrollbarArea == __instance)
     {
         var newIndex = (int)((state.endIndex) * (1.0f - __instance.verticalNormalizedPosition));
         if (state.filteredInventory.Count < PatchMechlabLimitItems.itemsOnScreen)
         {
             newIndex = 0;
         }
         if (state.index != newIndex)
         {
             state.index = newIndex;
             LogDebug(string.Format("[LimitItems] Refresh with: {0} {1}", newIndex, __instance.verticalNormalizedPosition));
             state.Refresh(false);
         }
     }
 }
        int UnityEngineUIScrollRect_m_IsActive(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;


            UnityEngine.UI.ScrollRect gen_to_be_invoked = (UnityEngine.UI.ScrollRect)translator.FastGetCSObj(L, 1);


            {
                bool gen_ret = gen_to_be_invoked.IsActive(  );
                LuaAPI.lua_pushboolean(L, gen_ret);



                return(1);
            }
        }
        static StackObject *OnEndDrag_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.EventSystems.PointerEventData @eventData = (UnityEngine.EventSystems.PointerEventData) typeof(UnityEngine.EventSystems.PointerEventData).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.UI.ScrollRect instance_of_this_method = (UnityEngine.UI.ScrollRect) typeof(UnityEngine.UI.ScrollRect).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.OnEndDrag(@eventData);

            return(__ret);
        }
        int UnityEngineUIScrollRect_m_OnDrag(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;


            UnityEngine.UI.ScrollRect gen_to_be_invoked = (UnityEngine.UI.ScrollRect)translator.FastGetCSObj(L, 1);


            {
                UnityEngine.EventSystems.PointerEventData _eventData = (UnityEngine.EventSystems.PointerEventData)translator.GetObject(L, 2, typeof(UnityEngine.EventSystems.PointerEventData));

                gen_to_be_invoked.OnDrag(_eventData);



                return(0);
            }
        }
        int UnityEngineUIScrollRect_m_Rebuild(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;


            UnityEngine.UI.ScrollRect gen_to_be_invoked = (UnityEngine.UI.ScrollRect)translator.FastGetCSObj(L, 1);


            {
                UnityEngine.UI.CanvasUpdate _executing; translator.Get(L, 2, out _executing);

                gen_to_be_invoked.Rebuild(_executing);



                return(0);
            }
        }
Esempio n. 7
0
        static int _m_SetLayoutVertical(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.UI.ScrollRect __cl_gen_to_be_invoked = (UnityEngine.UI.ScrollRect)translator.FastGetCSObj(L, 1);


            try {
                {
                    __cl_gen_to_be_invoked.SetLayoutVertical(  );



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
		public override void OnEnter()
		{

			GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject);
			if (_go!=null)
			{
				_scrollRect = _go.GetComponent<UnityEngine.UI.ScrollRect>();
			}

			if (resetOnExit.Value)
			{
				_originalValue = _scrollRect.normalizedPosition;
			}

			DoSetValue();

			if (!everyFrame)
			{
				Finish();
			}
		}
        public override void OnEnter()
        {
            GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (_go != null)
            {
                _scrollRect = _go.GetComponent <UnityEngine.UI.ScrollRect>();
            }

            if (resetOnExit.Value)
            {
                _originalValue = _scrollRect.normalizedPosition;
            }

            DoSetValue();

            if (!everyFrame)
            {
                Finish();
            }
        }
        static int _m_GraphicUpdateComplete(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UnityEngine.UI.ScrollRect gen_to_be_invoked = (UnityEngine.UI.ScrollRect)translator.FastGetCSObj(L, 1);



                {
                    gen_to_be_invoked.GraphicUpdateComplete(  );



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Esempio n. 11
0
        static int _m_IsActive(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.UI.ScrollRect __cl_gen_to_be_invoked = (UnityEngine.UI.ScrollRect)translator.FastGetCSObj(L, 1);


            try {
                {
                    bool __cl_gen_ret = __cl_gen_to_be_invoked.IsActive(  );
                    LuaAPI.lua_pushboolean(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
        static int _m_CalculateLayoutInputHorizontal(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UnityEngine.UI.ScrollRect gen_to_be_invoked = (UnityEngine.UI.ScrollRect)translator.FastGetCSObj(L, 1);



                {
                    gen_to_be_invoked.CalculateLayoutInputHorizontal(  );



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Esempio n. 13
0
        static int _m_OnDrag(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.UI.ScrollRect __cl_gen_to_be_invoked = (UnityEngine.UI.ScrollRect)translator.FastGetCSObj(L, 1);


            try {
                {
                    UnityEngine.EventSystems.PointerEventData eventData = (UnityEngine.EventSystems.PointerEventData)translator.GetObject(L, 2, typeof(UnityEngine.EventSystems.PointerEventData));

                    __cl_gen_to_be_invoked.OnDrag(eventData);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Esempio n. 14
0
        static int _m_Rebuild(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.UI.ScrollRect __cl_gen_to_be_invoked = (UnityEngine.UI.ScrollRect)translator.FastGetCSObj(L, 1);


            try {
                {
                    UnityEngine.UI.CanvasUpdate executing; translator.Get(L, 2, out executing);

                    __cl_gen_to_be_invoked.Rebuild(executing);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Esempio n. 15
0
        protected override void CreateBG(Transform parent)
        {
            base.CreateBG(parent);

            scrollBG     = new GameObject("scrollBG");
            scrollBG.tag = tag;
            scrollBG.AddComponent <UnityEngine.UI.Image>().color = Color.clear;
            scrollBG.transform.SetParent(bg.transform);
            scrollBG.AddComponent <UnityEngine.UI.RectMask2D>();
            UnityEngine.UI.ScrollRect scrollRect = scrollBG.AddComponent <UnityEngine.UI.ScrollRect>();

            scrollArea     = new GameObject("scroll");
            scrollArea.tag = tag;
            scrollArea.AddComponent <RectTransform>();
            scrollArea.transform.SetParent(scrollBG.transform);

            scrollBar     = new GameObject("scrollbar");
            scrollBar.tag = tag;
            scrollBar.AddComponent <RectTransform>();
            scrollBar.transform.SetParent(bg.transform);
            UnityEngine.UI.Scrollbar scrollBarCmp = scrollBar.AddComponent <UnityEngine.UI.Scrollbar>();
            scrollBarCmp.direction       = UnityEngine.UI.Scrollbar.Direction.BottomToTop;
            scrollRect.verticalScrollbar = scrollBarCmp;

            scrollBarHandle     = new GameObject("scrollbarhandle");
            scrollBarHandle.tag = tag;
            scrollBarHandle.AddComponent <UnityEngine.UI.Image>();
            scrollBarHandle.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 0.7f);
            scrollBarHandle.transform.SetParent(scrollBar.transform);

            scrollBarCmp.handleRect           = scrollBarHandle.GetComponent <RectTransform>();
            scrollBarCmp.handleRect.offsetMin = Vector2.zero;
            scrollBarCmp.handleRect.offsetMax = Vector2.zero;

            scrollRect.content           = scrollArea.GetComponent <RectTransform>();;
            scrollRect.horizontal        = false;
            scrollRect.scrollSensitivity = 40f;
        }
Esempio n. 16
0
        // Start is called before the first frame update
        private void Start()
        {
            _main = GetComponentInParent <UI_Main>();
            if (scrollView == null)
            {
                scrollView = GetComponent <UnityEngine.UI.ScrollRect>();
            }
            //var trigger = GetComponent<EventTrigger>();
            EventTrigger.Entry entryBegin     = new EventTrigger.Entry(),
                               entryDrag      = new EventTrigger.Entry(),
                               entryEnd       = new EventTrigger.Entry(),
                               entrypotential = new EventTrigger.Entry(),
                               entryScroll    = new EventTrigger.Entry();

            entryBegin.eventID = EventTriggerType.BeginDrag;
            //entryBegin.callback.AddListener(data => { scrollView.OnBeginDrag((PointerEventData)data); });
            //entryBegin.callback.AddListener(data => { _main.OnBeginDrag(data);});
            this.triggers.Add(entryBegin);

            entryDrag.eventID = EventTriggerType.Drag;
            //entryDrag.callback.AddListener(data => { scrollView.OnDrag((PointerEventData)data); });
            //entryDrag.callback.AddListener(data => { _main.OnDrag(data); });
            this.triggers.Add(entryDrag);

            entryEnd.eventID = EventTriggerType.EndDrag;
            entryEnd.callback.AddListener(data => { scrollView.OnEndDrag((PointerEventData)data); });
            entryEnd.callback.AddListener(data => { _main.OnEndDrag(data); });
            this.triggers.Add(entryEnd);

            entrypotential.eventID = EventTriggerType.InitializePotentialDrag;
            entrypotential.callback.AddListener(data => { scrollView.OnInitializePotentialDrag((PointerEventData)data); });
            this.triggers.Add(entrypotential);

            entryScroll.eventID = EventTriggerType.Scroll;
            entryScroll.callback.AddListener(data => { scrollView.OnScroll((PointerEventData)data); });
            this.triggers.Add(entryScroll);
        }
Esempio n. 17
0
 /// <summary>
 /// Description : Stop scrolling system from a scroll view
 /// </summary>
 public static void StopScroll(this UnityEngine.UI.ScrollRect pScrollRect)
 {
     pScrollRect.enabled = false;
 }
Esempio n. 18
0
 /// <summary>
 /// Description : Scroll to the bottom of a scroll rect
 /// </summary>
 /// <param name="pScrollRect">Scrollrect</param>
 public static void ScrollToBottom(this UnityEngine.UI.ScrollRect pScrollRect)
 {
     pScrollRect.normalizedPosition = new Vector2(0, 0);
 }
Esempio n. 19
0
 public override void InitDataBase(UnityEngine.UI.ScrollRect rect, Object pre, int numberOfPerLine, float cellWidth, float cellHeight, float cellPath, Vector3 firstCellPos)
 {
     base.InitDataBase(rect, pre, numberOfPerLine, cellWidth, cellHeight, cellPath, firstCellPos);
 }
            public void Create(PxPre.FileBrowse.FileBrowseProp prop, FileBrowser browser)
            {
                this.parentBrowser = browser;
                this.properties    = prop;

                const float scrollHorizHeight = 40.0f;
                const float scrollVertWidth   = 40.0f;

                GameObject goBrowseView = new GameObject("BrowseView");

                goBrowseView.transform.SetParent(this.gameObject.transform);
                goBrowseView.transform.localScale    = Vector3.one;
                goBrowseView.transform.localRotation = Quaternion.identity;
                RectTransform rtBrowseView = goBrowseView.AddComponent <RectTransform>();

                rtBrowseView.anchorMin = Vector2.zero;
                rtBrowseView.anchorMax = Vector2.one;
                rtBrowseView.pivot     = new Vector2(0.0f, 1.0f);
                rtBrowseView.offsetMin = new Vector2(5.0f, 5.0f);
                rtBrowseView.offsetMax = new Vector2(-5.0f, -5.0f);

                GameObject goViewport = new GameObject("Viewport");

                goViewport.transform.SetParent(goBrowseView.transform);
                goViewport.transform.localScale    = Vector3.one;
                goViewport.transform.localRotation = Quaternion.identity;
                RectTransform rtVP = goViewport.AddComponent <RectTransform>();

                rtVP.anchorMin = Vector2.zero;
                rtVP.anchorMax = Vector2.one;
                rtVP.pivot     = new Vector2(0.0f, 1.0f);
                rtVP.offsetMin = new Vector2(0.0f, scrollHorizHeight);
                rtVP.offsetMax = new Vector2(-scrollVertWidth, 0.0f);
                UnityEngine.UI.Image imgViewport = goViewport.AddComponent <UnityEngine.UI.Image>();
                UnityEngine.UI.Mask  maskVP      = goViewport.AddComponent <UnityEngine.UI.Mask>();


                GameObject goContent = new GameObject("Content");

                goContent.transform.SetParent(goViewport.transform);
                goContent.transform.localScale    = Vector3.one;
                goContent.transform.localRotation = Quaternion.identity;
                RectTransform rtContent = goContent.AddComponent <RectTransform>();

                rtContent.anchorMin = new Vector2(0.0f, 1.0f);
                rtContent.anchorMax = new Vector2(0.0f, 1.0f);
                rtContent.pivot     = new Vector2(0.0f, 1.0f);
                rtContent.offsetMin = new Vector2(0.0f, -10.0f);
                rtContent.offsetMax = new Vector2(10.0f, 0.0f);

                //      VERT SCROLL
                //
                ////////////////////////////////////////////////////////////////////////////////
                ///
                GameObject goVertScroll = new GameObject("VertScroll");

                goVertScroll.transform.SetParent(goBrowseView.transform);
                goVertScroll.transform.localScale    = Vector3.one;
                goVertScroll.transform.localRotation = Quaternion.identity;
                RectTransform rtVertScr = goVertScroll.AddComponent <RectTransform>();

                rtVertScr.anchorMin = new Vector2(1.0f, 0.0f);
                rtVertScr.anchorMax = new Vector2(1.0f, 1.0f);
                rtVertScr.pivot     = new Vector2(0.0f, 1.0f);
                rtVertScr.offsetMin = new Vector2(-scrollVertWidth, scrollHorizHeight);
                rtVertScr.offsetMax = new Vector2(0.0f, 0.0f);
                UnityEngine.UI.Image imgVertScr = goVertScroll.AddComponent <UnityEngine.UI.Image>();
                imgVertScr.sprite = this.properties.sliderSprite;
                imgVertScr.type   = UnityEngine.UI.Image.Type.Sliced;


                GameObject goVertThumb = new GameObject("VertThumb");

                goVertThumb.transform.SetParent(goVertScroll.transform);
                goVertThumb.transform.localScale    = Vector3.one;
                goVertThumb.transform.localRotation = Quaternion.identity;
                RectTransform rtVertThumb = goVertThumb.AddComponent <RectTransform>();

                rtVertThumb.pivot     = new Vector2(0.0f, 1.0f);
                rtVertThumb.offsetMin = Vector2.zero;
                rtVertThumb.offsetMax = Vector2.zero;
                UnityEngine.UI.Image imgVertThumb = goVertThumb.AddComponent <UnityEngine.UI.Image>();

                UnityEngine.UI.Scrollbar sbVert = goVertScroll.AddComponent <UnityEngine.UI.Scrollbar>();
                sbVert.handleRect    = rtVertThumb;
                sbVert.direction     = UnityEngine.UI.Scrollbar.Direction.BottomToTop;
                sbVert.targetGraphic = imgVertThumb;

                this.properties.sliderThumb.Apply(sbVert, imgVertThumb);

                //      HORIZ SCROLL
                //
                ////////////////////////////////////////////////////////////////////////////////
                ///
                GameObject goHorizScroll = new GameObject("HorizScroll");

                goHorizScroll.transform.SetParent(goBrowseView.transform);
                goHorizScroll.transform.localScale    = Vector3.one;
                goHorizScroll.transform.localRotation = Quaternion.identity;
                RectTransform rtHorizScr = goHorizScroll.AddComponent <RectTransform>();

                rtHorizScr.anchorMin = new Vector2(0.0f, 0.0f);
                rtHorizScr.anchorMax = new Vector2(1.0f, 0.0f);
                rtHorizScr.pivot     = new Vector2(0.0f, 1.0f);
                rtHorizScr.offsetMin = Vector2.zero;
                rtHorizScr.offsetMax = new Vector2(-scrollVertWidth, scrollHorizHeight);
                UnityEngine.UI.Image imgHorzScr = goHorizScroll.AddComponent <UnityEngine.UI.Image>();
                imgHorzScr.sprite = this.properties.sliderSprite;
                imgHorzScr.type   = UnityEngine.UI.Image.Type.Sliced;

                GameObject goHorizThumb = new GameObject("HorizThumb");

                goHorizThumb.transform.SetParent(rtHorizScr);
                goHorizThumb.transform.localScale    = Vector3.one;
                goHorizThumb.transform.localRotation = Quaternion.identity;
                RectTransform rtHorizThumb = goHorizThumb.AddComponent <RectTransform>();

                rtHorizThumb.pivot     = new Vector2(0.0f, 1.0f);
                rtHorizThumb.offsetMin = Vector2.zero;
                rtHorizThumb.offsetMax = Vector2.zero;
                UnityEngine.UI.Image imgHorizThumb = goHorizThumb.AddComponent <UnityEngine.UI.Image>();

                UnityEngine.UI.Scrollbar sbHoriz = goHorizScroll.AddComponent <UnityEngine.UI.Scrollbar>();
                sbHoriz.handleRect = rtHorizThumb;
                sbHoriz.direction  = UnityEngine.UI.Scrollbar.Direction.LeftToRight;

                this.properties.sliderThumb.Apply(sbHoriz, imgHorizThumb);

                //      RECT
                //
                ////////////////////////////////////////////////////////////////////////////////

                this.scrollRect                     = goBrowseView.AddComponent <UnityEngine.UI.ScrollRect>();
                this.scrollRect.viewport            = rtVP;
                this.scrollRect.content             = rtContent;
                this.scrollRect.horizontalScrollbar = sbHoriz;
                this.scrollRect.verticalScrollbar   = sbVert;
                this.scrollRect.scrollSensitivity   = this.properties.fileScrollSensitivity;

                //      FIN
                //
                ////////////////////////////////////////////////////////////////////////////////

                // Make dirty
                this.scrollRect.gameObject.SetActive(false);
                this.scrollRect.gameObject.SetActive(true);
            }
 /// <summary>Tweens a ScrollRect's verticalNormalizedPosition to the given value.
 /// Also stores the ScrollRect as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 public static Tweener DOVerticalNormalizedPos(this UnityEngine.UI.ScrollRect target, float endValue, float duration, bool snapping = false)
 {
     return(DOTween.To(() => target.verticalNormalizedPosition, x => target.verticalNormalizedPosition = x, endValue, duration)
            .SetOptions(snapping).SetTarget(target));
 }
Esempio n. 22
0
 /// <summary> Scroll to a child of the content </summary>
 /// <param name="scroll">The ScrollRect</param>
 /// <param name="target">The child to scroll to</param>
 /// <param name="myMonoBehaviour">Any MonoBehaviour script</param>
 public static void SnapTo(this UnityEngine.UI.ScrollRect scroll, Transform target, MonoBehaviour myMonoBehaviour)
 {
     myMonoBehaviour.StartCoroutine(Snap(scroll, target));
 }
Esempio n. 23
0
        void InitScrollView(GameObject windows)
        {
            //content_scroll_view
            GameObject scrollView = new GameObject("scrollview");
            scrollView.transform.parent = windows.transform;
            sr_content = scrollView.AddComponent<UnityEngine.UI.ScrollRect>();
            sr_content.horizontal = false;

            UnityEngine.UI.Image img_sr = scrollView.AddComponent<UnityEngine.UI.Image>();
            img_sr.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 0);
            img_sr.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, -30);
            img_sr.rectTransform.anchorMin = new Vector2(0, 0.3f);
            img_sr.rectTransform.anchorMax = new Vector2(1, 1);
            img_sr.rectTransform.pivot = new Vector2(0.5f, 0.5f);
            img_sr.color = new Color(0, 0, 0, 1f);
            UnityEngine.UI.Mask mask = scrollView.AddComponent<UnityEngine.UI.Mask>();
            mask.showMaskGraphic = false;
        }
Esempio n. 24
0
        // Draw the expansions on the screen, highlighting those that are enabled
        public void DrawList(string type = "")
        {
            // Clean up
            Destroyer.Dialog();
            // Initialise selected list
            selected = new List <string>();

            // Fetch which packs are selected from the current config (items under [Packs])
            Dictionary <string, string> setPacks = game.config.data.Get(game.gameType.TypeName() + "Packs");

            if (setPacks != null)
            {
                foreach (KeyValuePair <string, string> kv in setPacks)
                {
                    // As packs are just a list, only the key is used, value is empty
                    selected.Add(kv.Key);
                }
            }

            // Draw a header
            DialogBox db = new DialogBox(
                new Vector2(2, 1),
                new Vector2(UIScaler.GetWidthUnits() - 4, 2),
                SELECT_EXPANSION
                );

            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
            db.SetFont(game.gameType.GetHeaderFont());

            db = new DialogBox(new Vector2(1, 4f), new Vector2(UIScaler.GetWidthUnits() - 2f, 22f), StringKey.NULL);
            db.AddBorder();
            db.background.AddComponent <UnityEngine.UI.Mask>();
            UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>();

            GameObject    scrollArea      = new GameObject("scroll");
            RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>();

            scrollArea.transform.parent = db.background.transform;
            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1);
            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit());

            GameObject scrollBarObj = new GameObject("scrollbar");

            scrollBarObj.transform.parent = db.background.transform;
            RectTransform scrollBarRect = scrollBarObj.AddComponent <RectTransform>();

            scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 22 * UIScaler.GetPixelsPerUnit());
            scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit(), 1 * UIScaler.GetPixelsPerUnit());
            UnityEngine.UI.Scrollbar scrollBar = scrollBarObj.AddComponent <UnityEngine.UI.Scrollbar>();
            scrollBar.direction          = UnityEngine.UI.Scrollbar.Direction.BottomToTop;
            scrollRect.verticalScrollbar = scrollBar;

            GameObject scrollBarHandle = new GameObject("scrollbarhandle");

            scrollBarHandle.transform.parent = scrollBarObj.transform;
            //RectTransform scrollBarHandleRect = scrollBarHandle.AddComponent<RectTransform>();
            scrollBarHandle.AddComponent <UnityEngine.UI.Image>();
            scrollBarHandle.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 0.7f);
            scrollBar.handleRect           = scrollBarHandle.GetComponent <RectTransform>();
            scrollBar.handleRect.offsetMin = Vector2.zero;
            scrollBar.handleRect.offsetMax = Vector2.zero;

            scrollRect.content    = scrollInnerRect;
            scrollRect.horizontal = false;

            buttons = new Dictionary <string, List <TextButton> >();
            // Start here
            float      offset = 4.5f;
            TextButton tb     = null;
            bool       left   = true;

            // Note this is currently unordered
            foreach (ContentData.ContentPack cp in game.cd.allPacks)
            {
                // If the id is "" this is base content and can be ignored
                if (cp.id.Length > 0 && cp.type.Equals(type))
                {
                    string id = cp.id;
                    buttons.Add(id, new List <TextButton>());
                    Color bgColor = Color.white;
                    if (!selected.Contains(id))
                    {
                        bgColor = new Color(0.3f, 0.3f, 0.3f);
                    }

                    // Create a sprite with the pack's image
                    Texture2D tex    = ContentData.FileToTexture(cp.image);
                    Sprite    sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1);

                    if (left)
                    {
                        tb = new TextButton(new Vector2(2f, offset), new Vector2(6, 6), StringKey.NULL, delegate { Select(id); });
                    }
                    else
                    {
                        tb = new TextButton(new Vector2(UIScaler.GetWidthUnits() - 9, offset), new Vector2(6, 6), StringKey.NULL, delegate { Select(id); });
                    }
                    tb.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite;
                    tb.background.transform.parent = scrollArea.transform;
                    tb.background.GetComponent <UnityEngine.UI.Image>().color = bgColor;
                    buttons[id].Add(tb);

                    if (left)
                    {
                        tb = new TextButton(new Vector2(8, offset + 1.5f), new Vector2(UIScaler.GetWidthUnits() - 19, 3), new StringKey("val", "INDENT", new StringKey(game.cd.GetContentName(id), false)), delegate { Select(id); }, Color.clear);
                    }
                    else
                    {
                        tb = new TextButton(new Vector2(10, offset + 1.5f), new Vector2(UIScaler.GetWidthUnits() - 20, 3), new StringKey("val", "INDENT", new StringKey(game.cd.GetContentName(id), false)), delegate { Select(id); }, Color.clear);
                    }
                    tb.background.GetComponent <UnityEngine.UI.Image>().color = bgColor;
                    tb.background.transform.parent = scrollArea.transform;
                    buttons[id].Add(tb);

                    if (left)
                    {
                        tb = new TextButton(new Vector2(9, offset + 1.5f), new Vector2(UIScaler.GetWidthUnits() - 19, 3), new StringKey(game.cd.GetContentName(id), false), delegate { Select(id); }, Color.black);
                    }
                    else
                    {
                        tb = new TextButton(new Vector2(11, offset + 1.5f), new Vector2(UIScaler.GetWidthUnits() - 20, 3), new StringKey(game.cd.GetContentName(id), false), delegate { Select(id); }, Color.black);
                    }
                    tb.setColor(Color.clear);
                    tb.button.GetComponent <UnityEngine.UI.Text>().color     = Color.black;
                    tb.button.GetComponent <UnityEngine.UI.Text>().material  = (Material)Resources.Load("Fonts/FontMaterial");
                    tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft;
                    //tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
                    tb.SetFont(game.gameType.GetHeaderFont());
                    tb.background.GetComponent <UnityEngine.UI.Image>().color = bgColor;
                    tb.background.transform.parent = scrollArea.transform;
                    buttons[id].Add(tb);

                    left    = !left;
                    offset += 4f;
                }
            }
            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 2.5f) * UIScaler.GetPixelsPerUnit());

            // Button for back to main menu
            if (game.cd.packTypes.Count > 1)
            {
                tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { DrawTypeList(); }, Color.red);
            }
            else
            {
                tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Destroyer.MainMenu(); }, Color.red);
            }
            tb.SetFont(game.gameType.GetHeaderFont());
        }
Esempio n. 25
0
 /// <summary>
 /// Read the data using the reader.
 /// </summary>
 /// <param name="reader">Reader.</param>
 public override object Read(ISaveGameReader reader)
 {
     UnityEngine.UI.ScrollRect scrollRect = SaveGameType.CreateComponent <UnityEngine.UI.ScrollRect> ();
     ReadInto(scrollRect, reader);
     return(scrollRect);
 }
Esempio n. 26
0
 void Awake()
 {
     btn = Resources.Load<UnityEngine.UI.Button>(S_ANSWER_BTN_PREFAB);
     textRectObj = GameObject.Find(S_TEXT_RECT);
     textPanelObj = GameObject.Find(S_TEXT_PLANE);
     if (textPanelObj != null)
     {
         storyTextObj = textPanelObj.GetComponent<UnityEngine.UI.Text>();
     }
     sr = GetComponentInChildren<UnityEngine.UI.ScrollRect>();
 }
Esempio n. 27
0
        public QuestSelectionScreen(Dictionary <string, QuestData.Quest> ql)
        {
            questList = ql;
            Game game = Game.Get();

            // If a dialog window is open we force it closed (this shouldn't happen)
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
            {
                Object.Destroy(go);
            }

            // Clean up downloader if present
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("questui"))
            {
                Object.Destroy(go);
            }

            // Heading
            DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Select " + game.gameType.QuestName());

            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
            db.SetFont(game.gameType.GetHeaderFont());

            db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), "");
            db.AddBorder();
            db.background.AddComponent <UnityEngine.UI.Mask>();
            UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>();

            GameObject    scrollArea      = new GameObject("scroll");
            RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>();

            scrollArea.transform.parent = db.background.transform;
            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1);
            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit());

            scrollRect.content    = scrollInnerRect;
            scrollRect.horizontal = false;

            TextButton tb;
            // Start here
            float offset = 5;

            // Loop through all available quests
            foreach (KeyValuePair <string, QuestData.Quest> q in questList)
            {
                if (q.Value.GetMissingPacks(game.cd.GetEnabledPackIDs()).Count == 0)
                {
                    string key = q.Key;
                    // Size is 1.2 to be clear of characters with tails
                    tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), "  " + q.Value.name, delegate { Selection(key); }, Color.black, (int)offset);
                    tb.button.GetComponent <UnityEngine.UI.Text>().material   = (Material)Resources.Load("Fonts/FontMaterial");
                    tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
                    tb.button.GetComponent <UnityEngine.UI.Text>().alignment  = TextAnchor.MiddleLeft;
                    tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white;
                    tb.background.transform.parent = scrollArea.transform;
                    offset += 2;
                }
            }

            // Loop through all unavailable quests
            foreach (KeyValuePair <string, QuestData.Quest> q in questList)
            {
                if (q.Value.GetMissingPacks(game.cd.GetEnabledPackIDs()).Count > 0)
                {
                    // Size is 1.2 to be clear of characters with tails
                    db = new DialogBox(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), "  " + q.Value.name, Color.black);
                    db.textObj.GetComponent <UnityEngine.UI.Text>().material  = (Material)Resources.Load("Fonts/FontMaterial");
                    db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft;
                    db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.4f, 0.4f, 0.4f);
                    db.background.transform.parent = scrollArea.transform;
                    offset += 1.2f;
                    foreach (string s in q.Value.GetMissingPacks(game.cd.GetEnabledPackIDs()))
                    {
                        db = new DialogBox(new Vector2(4, offset), new Vector2(UIScaler.GetWidthUnits() - 9, 1.2f), " Requires:  " + game.cd.GetContentName(s), Color.black);
                        db.textObj.GetComponent <UnityEngine.UI.Text>().material  = (Material)Resources.Load("Fonts/FontMaterial");
                        db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft;
                        db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.4f, 0.4f, 0.4f);
                        db.background.transform.parent = scrollArea.transform;
                        offset += 1.2f;
                    }
                }
                offset += 0.8f;
            }

            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit());

            tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Cancel(); }, Color.red);
            tb.SetFont(game.gameType.GetHeaderFont());

            tb = new TextButton(new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2), "Download", delegate { Download(); }, Color.green);
            tb.SetFont(game.gameType.GetHeaderFont());
        }
Esempio n. 28
0
        public static IEnumerator SetVertScrollLater(UnityEngine.UI.ScrollRect sr, float val)
        {
            yield return(new WaitForEndOfFrame());

            sr.verticalNormalizedPosition = val;
        }
        public QuestSelectionScreen(Dictionary <string, QuestData.Quest> ql)
        {
            questList = ql;
            Game game = Game.Get();

            // If a dialog window is open we force it closed (this shouldn't happen)
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
            {
                Object.Destroy(go);
            }

            // Clean up downloader if present
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("questui"))
            {
                Object.Destroy(go);
            }

            // Heading
            DialogBox db = new DialogBox(
                new Vector2(2, 1),
                new Vector2(UIScaler.GetWidthUnits() - 4, 3),
                new StringKey("val", "SELECT", game.gameType.QuestName())
                );

            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
            db.SetFont(game.gameType.GetHeaderFont());

            db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), StringKey.NULL);
            db.AddBorder();
            db.background.AddComponent <UnityEngine.UI.Mask>();
            UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>();

            GameObject scrollBarObj = new GameObject("scrollbar");

            scrollBarObj.transform.parent = db.background.transform;
            RectTransform scrollBarRect = scrollBarObj.AddComponent <RectTransform>();

            scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 21 * UIScaler.GetPixelsPerUnit());
            scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit(), 1 * UIScaler.GetPixelsPerUnit());
            UnityEngine.UI.Scrollbar scrollBar = scrollBarObj.AddComponent <UnityEngine.UI.Scrollbar>();
            scrollBar.direction          = UnityEngine.UI.Scrollbar.Direction.BottomToTop;
            scrollRect.verticalScrollbar = scrollBar;

            GameObject scrollBarHandle = new GameObject("scrollbarhandle");

            scrollBarHandle.transform.parent = scrollBarObj.transform;
            //RectTransform scrollBarHandleRect = scrollBarHandle.AddComponent<RectTransform>();
            scrollBarHandle.AddComponent <UnityEngine.UI.Image>();
            scrollBarHandle.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 0.7f);
            scrollBar.handleRect           = scrollBarHandle.GetComponent <RectTransform>();
            scrollBar.handleRect.offsetMin = Vector2.zero;
            scrollBar.handleRect.offsetMax = Vector2.zero;

            GameObject    scrollArea      = new GameObject("scroll");
            RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>();

            scrollArea.transform.parent = db.background.transform;
            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1);
            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit());

            scrollRect.content    = scrollInnerRect;
            scrollRect.horizontal = false;

            TextButton tb;
            // Start here
            float offset = 5;

            // Loop through all available quests
            foreach (KeyValuePair <string, QuestData.Quest> q in questList)
            {
                if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count == 0)
                {
                    string key = q.Key;
                    LocalizationRead.scenarioDict = q.Value.localizationDict;
                    string translation = q.Value.name.Translate();

                    // Size is 1.2 to be clear of characters with tails
                    tb = new TextButton(
                        new Vector2(2, offset),
                        new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f),
                        new StringKey("val", "INDENT", translation),
                        delegate { Selection(key); }, Color.black, (int)offset);
                    tb.button.GetComponent <UnityEngine.UI.Text>().material   = (Material)Resources.Load("Fonts/FontMaterial");
                    tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
                    tb.button.GetComponent <UnityEngine.UI.Text>().alignment  = TextAnchor.MiddleLeft;
                    tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white;
                    tb.background.transform.parent = scrollArea.transform;
                    offset += 2;
                }
            }

            // Loop through all unavailable quests
            foreach (KeyValuePair <string, QuestData.Quest> q in questList)
            {
                if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count > 0)
                {
                    string key = q.Key;
                    LocalizationRead.scenarioDict = q.Value.localizationDict;
                    string translation = q.Value.name.Translate();

                    // Size is 1.2 to be clear of characters with tails
                    db = new DialogBox(
                        new Vector2(2, offset),
                        new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f),
                        new StringKey("val", "INDENT", translation),
                        Color.black);
                    db.textObj.GetComponent <UnityEngine.UI.Text>().material  = (Material)Resources.Load("Fonts/FontMaterial");
                    db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft;
                    db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.4f, 0.4f, 0.4f);
                    db.background.transform.parent = scrollArea.transform;
                    offset += 1.2f;
                    foreach (string s in q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()))
                    {
                        db = new DialogBox(
                            new Vector2(4, offset),
                            new Vector2(UIScaler.GetWidthUnits() - 9, 1.2f),
                            // TODO: Expansion names should be keys too
                            new StringKey("val", "REQUIRES_EXPANSION", game.cd.GetContentName(s)),
                            Color.black);
                        db.textObj.GetComponent <UnityEngine.UI.Text>().material  = (Material)Resources.Load("Fonts/FontMaterial");
                        db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft;
                        db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.4f, 0.4f, 0.4f);
                        db.background.transform.parent = scrollArea.transform;
                        offset += 1.2f;
                    }
                }
                offset += 0.8f;
            }

            scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit());

            tb = new TextButton(
                new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2),
                CommonStringKeys.BACK, delegate { Cancel(); }, Color.red);

            tb.SetFont(game.gameType.GetHeaderFont());

            tb = new TextButton(
                new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2),
                DOWNLOAD, delegate { Download(); }, Color.green);
            tb.SetFont(game.gameType.GetHeaderFont());
        }
Esempio n. 30
0
        /// <summary>
        /// Read the data into the specified value.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="reader">Reader.</param>
        public override void ReadInto(object value, ISaveGameReader reader)
        {
            UnityEngine.UI.ScrollRect scrollRect = (UnityEngine.UI.ScrollRect)value;
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "content":
                    if (scrollRect.content == null)
                    {
                        scrollRect.content = reader.ReadProperty <UnityEngine.RectTransform> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.RectTransform> (scrollRect.content);
                    }
                    break;

                case "horizontal":
                    scrollRect.horizontal = reader.ReadProperty <System.Boolean> ();
                    break;

                case "vertical":
                    scrollRect.vertical = reader.ReadProperty <System.Boolean> ();
                    break;

                case "movementType":
                    scrollRect.movementType = reader.ReadProperty <UnityEngine.UI.ScrollRect.MovementType> ();
                    break;

                case "elasticity":
                    scrollRect.elasticity = reader.ReadProperty <System.Single> ();
                    break;

                case "inertia":
                    scrollRect.inertia = reader.ReadProperty <System.Boolean> ();
                    break;

                case "decelerationRate":
                    scrollRect.decelerationRate = reader.ReadProperty <System.Single> ();
                    break;

                case "scrollSensitivity":
                    scrollRect.scrollSensitivity = reader.ReadProperty <System.Single> ();
                    break;

                case "viewport":
                    if (scrollRect.viewport == null)
                    {
                        scrollRect.viewport = reader.ReadProperty <UnityEngine.RectTransform> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.RectTransform> (scrollRect.viewport);
                    }
                    break;

                case "horizontalScrollbar":
                    if (scrollRect.horizontalScrollbar == null)
                    {
                        scrollRect.horizontalScrollbar = reader.ReadProperty <UnityEngine.UI.Scrollbar> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.UI.Scrollbar> (scrollRect.horizontalScrollbar);
                    }
                    break;

                case "verticalScrollbar":
                    if (scrollRect.verticalScrollbar == null)
                    {
                        scrollRect.verticalScrollbar = reader.ReadProperty <UnityEngine.UI.Scrollbar> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.UI.Scrollbar> (scrollRect.verticalScrollbar);
                    }
                    break;

                case "horizontalScrollbarVisibility":
                    scrollRect.horizontalScrollbarVisibility = reader.ReadProperty <UnityEngine.UI.ScrollRect.ScrollbarVisibility> ();
                    break;

                case "verticalScrollbarVisibility":
                    scrollRect.verticalScrollbarVisibility = reader.ReadProperty <UnityEngine.UI.ScrollRect.ScrollbarVisibility> ();
                    break;

                case "horizontalScrollbarSpacing":
                    scrollRect.horizontalScrollbarSpacing = reader.ReadProperty <System.Single> ();
                    break;

                case "verticalScrollbarSpacing":
                    scrollRect.verticalScrollbarSpacing = reader.ReadProperty <System.Single> ();
                    break;

                case "velocity":
                    scrollRect.velocity = reader.ReadProperty <UnityEngine.Vector2> ();
                    break;

                case "normalizedPosition":
                    scrollRect.normalizedPosition = reader.ReadProperty <UnityEngine.Vector2> ();
                    break;

                case "horizontalNormalizedPosition":
                    scrollRect.horizontalNormalizedPosition = reader.ReadProperty <System.Single> ();
                    break;

                case "verticalNormalizedPosition":
                    scrollRect.verticalNormalizedPosition = reader.ReadProperty <System.Single> ();
                    break;

                case "useGUILayout":
                    scrollRect.useGUILayout = reader.ReadProperty <System.Boolean> ();
                    break;

                case "enabled":
                    scrollRect.enabled = reader.ReadProperty <System.Boolean> ();
                    break;

                case "tag":
                    scrollRect.tag = reader.ReadProperty <System.String> ();
                    break;

                case "name":
                    scrollRect.name = reader.ReadProperty <System.String> ();
                    break;

                case "hideFlags":
                    scrollRect.hideFlags = reader.ReadProperty <UnityEngine.HideFlags> ();
                    break;
                }
            }
        }