Пример #1
0
    public override void OnSpawn()
    {
        if (scrollRect == null)
        {
            scrollRect = GetComponent <ScrollRect>();
        }

        scrollRect.horizontal   = false;
        scrollRect.vertical     = true;
        scrollRect.movementType = ScrollRect.MovementType.Elastic;


        // Main image.
        mainImage = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(Image)).script as Image;

        // Image used for content ect.
        contentImage = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(Image)).script as Image;
        scrollBar    = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ScrollbarWrapper)).script as ScrollbarWrapper;

        content = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(UIMule)).script as UIMule;
        contentImage.gameObject.AddComponent <Mask>();

        content.GetRectTransform().pivot = new Vector3(0.5f, 1);
        content.GetRectTransform().SetParent(contentImage.transform);
        mainImage.transform.SetParent(scrollRect.transform);
        contentImage.transform.SetParent(scrollRect.transform);
        scrollBar.transform.SetParent(scrollRect.transform);

        (contentImage.transform as RectTransform).sizeDelta = new Vector2(100, 150);
        scrollBar.transform.localPosition = new Vector2(60, 0);
        //sBW.transform.localPosition = new Vector3(300,0);

        scrollRect.viewport          = contentImage.rectTransform;
        scrollRect.content           = content.GetRectTransform();
        scrollRect.verticalScrollbar = scrollBar.scriptsData[0].script as Scrollbar;
        //AllignWrapperElements();

        scriptsData = new AdditionalScriptData[] {
            new AdditionalScriptData("ScrollRect", scrollRect),
            new AdditionalScriptData("MainImage", mainImage),
            new AdditionalScriptData("ContentImage", contentImage),
            new AdditionalScriptData("Scrollbar", scrollBar),
            new AdditionalScriptData("Content", content)
        };
    }
Пример #2
0
 protected override void Dispose(bool disposing)
 {
     this.SuspendRedraw();
     if (this.m_TouchScrollingTimer != null)
     {
         this.m_TouchScrollingTimer.Dispose();
     }
     this.m_TouchScrollingTimer = null;
     BackBufferManager.Release();
     this.m_gradientBackColor = null;
     this.m_pages = null;
     if (this.m_ItemCollection != null)
     {
         this.m_ItemCollection.Clear();
     }
     this.m_ItemCollection = null;
     if (this.m_itemList != null)
     {
         this.m_itemList.Clear();
     }
     this.m_itemList = null;
     if (disposing)
     {
         foreach (Control control in this.m_Controls.Values)
         {
             control.Dispose();
         }
         this.m_Controls.Clear();
         if (this.m_vScroll != null)
         {
             this.m_vScroll.Detach();
         }
         this.m_vScroll = null;
     }
     if (m_sPen != null)
     {
         m_sPen.Dispose();
     }
     m_sPen = null;
     if (m_sPixel != null)
     {
         m_sPixel.Dispose();
     }
     m_sPixel = null;
     if (disposing && (this.components != null))
     {
         this.components.Dispose();
     }
     base.Dispose(disposing);
 }
Пример #3
0
 internal void SetVScrollBar(int height)
 {
     try
     {
         if (this.m_vScroll == null)
         {
             if (this.m_vScrollBarResco == null)
             {
                 this.m_vScroll = new ScrollbarWrapper(new System.Windows.Forms.VScrollBar(), ScrollOrientation.VerticalScroll);
             }
             else
             {
                 this.m_vScroll = new ScrollbarWrapper(this.m_vScrollBarResco, ScrollOrientation.VerticalScroll);
             }
             this.m_vScroll.TabStop = false;
             this.m_vScroll.Attach(this);
             this.m_vScroll.ValueChanged += new EventHandler(this.OnValueChanged);
             this.m_vScroll.Resize += new EventHandler(this.OnScrollResize);
             this.m_vScroll.BringToFront();
         }
         Rectangle rectangle = this.CalculateClientRect();
         Rectangle rectangle2 = new Rectangle();
         rectangle2.Width = this.m_VScrollBarWidth;
         rectangle2.Height = rectangle.Height - ((this.PageCount == 0) ? 0 : this.PagerHeight);
         rectangle2.X = (rectangle.X + rectangle.Width) - this.m_VScrollBarWidth;
         if (this.PagesLocation == RescoPagesLocation.Top)
         {
             rectangle2.Y = rectangle.Y + this.PagerHeight;
         }
         else
         {
             rectangle2.Y = rectangle.Y;
         }
         this.m_vScroll.Bounds = rectangle2;
         this.m_iPrevValue = this.m_vScroll.Value;
         this.m_vScroll.Maximum = height;
         this.m_vScroll.SmallChange = 20;
         int num = rectangle.Height - ((this.PageCount == 0) ? 0 : this.PagerHeight);
         this.m_vScroll.LargeChange = (num > 0) ? num : 0;
         if (this.m_vScroll.Maximum > this.m_vScroll.LargeChange)
         {
             if (!this.m_bScrollVisible)
             {
                 this.m_bScrollVisible = true;
                 this.m_vScroll.Show();
                 this.ResizeControls();
             }
             if (this.m_iPrevValue != this.m_vScroll.Value)
             {
                 this.OnValueChanged(this, new EventArgs());
             }
         }
         else
         {
             if (this.m_bScrollVisible)
             {
                 this.m_bScrollVisible = false;
                 this.m_vScroll.Hide();
                 this.ResizeControls();
             }
             this.m_vScroll.Value = 0;
             this.OnValueChanged(this, new EventArgs());
         }
     }
     catch (Exception)
     {
     }
 }