Search Unity

How to Freeze the Button in Scroll bar

Discussion in 'Scripting' started by Alexander21, Sep 18, 2019.

  1. Alexander21

    Alexander21

    Joined:
    Dec 14, 2015
    Posts:
    220
    Hi All


    In my project I have instantiate 25 buttons in the scroll bar..I am scrolling the button. It is working well.

    Actually i want freeze the 12 the button.When i scroll the button. The 12 th button should be constantly should be there and other button should scroll go up.

    constantly up and down go there but the freeze button should be constantly there.

    Like Excel. If we freeze the top row. The top row is constantly there and scrolling is happened.

    Like that i have to do in unity.


    How to Freeze the button in scroll bar.
     
  2. cmyd

    cmyd

    Joined:
    Oct 29, 2017
    Posts:
    92
    Just change button's parent object via button.parent = somethingElse and put after the scroll bar in your hierarchy
     
  3. Neriad

    Neriad

    Joined:
    Feb 12, 2016
    Posts:
    114
    You can use button.interactable to make a button not clickable anymore, but I'm not sure I understood the question though.
     
  4. Alexander21

    Alexander21

    Joined:
    Dec 14, 2015
    Posts:
    220
    Thanks cmyd and Neriad For Your reply........

    Actually I have uploaded new gif file. In that gif file 2 row is freezed (Row Heading1,Row Heading2, Row Heading3,RowHeading4).

    2nd row is constantly there. Rest of the the rows 4 to 100 rows are going up.

    Like that i have to do ...

    How can i do it..
     

    Attached Files:

  5. cmyd

    cmyd

    Joined:
    Oct 29, 2017
    Posts:
    92
    Just pop the buttons out of the scroll bar, change their parent,they will stay at that place, I can write you a little piece of code if you want.
     
  6. Alexander21

    Alexander21

    Joined:
    Dec 14, 2015
    Posts:
    220
    welcome. code needed...
     
  7. cmyd

    cmyd

    Joined:
    Oct 29, 2017
    Posts:
    92
    Is this what you want?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class ScrollCode : MonoBehaviour
    6. {
    7.  
    8.     [SerializeField]
    9.     Transform newParent;
    10.  
    11.     // Start is called before the first frame update
    12.     void Start()
    13.     {
    14.        
    15.     }
    16.  
    17.     // Update is called once per frame
    18.     void Update()
    19.     {
    20.        
    21.     }
    22.  
    23.     public void DeAttach(Transform target)
    24.     {
    25.         target.parent = newParent;
    26.     }
    27. }
    28.  
     

    Attached Files:

    • tset.gif
      tset.gif
      File size:
      47.6 KB
      Views:
      78
    • 2.png
      2.png
      File size:
      46 KB
      Views:
      66
    • 1.png
      1.png
      File size:
      6.9 KB
      Views:
      72
  8. Alexander21

    Alexander21

    Joined:
    Dec 14, 2015
    Posts:
    220
    @cmyd thank you so much.. It Works ..
     
  9. cmyd

    cmyd

    Joined:
    Oct 29, 2017
    Posts:
    92
    any time brother.