Hi I am trying to make a manual scroll inside a panel.I have added a panel first. I have added Vertical Layout Group,ContentSizeFitter,ScrollRect script and Mask script to the panel.Then I added an empty Gameobject as child of panel.To this empty Gameobject I added a some text.I have added this Gameobject as the Content to scroll in Scroll script.The problem I am facing is the scroll is either unrestricted or elastic.I want to scroll only according to the its contents not infinite scroll or elastic one.I tried to set Vertical fit in Content size fitter to preferred size but the whole panel shrinks.To get more idea I have added an image.
It looks like that you want manually create the ScrollView. Do you know that there is an UI Element called ScrollView? (see Unity Tutorial ScrollView) If I understand you right, you only want to scroll till the end of the text? In the following image you see my example. I made a ScrollView element and added a UI.Text Element to its content. With the two buttons I can switch between two texts with different length and the scroll bar changes its size to fit the length of the text. (In the Scroll Rect there are different MovementType options.)
On the Content Element you can add a Content Size Fitter and a Vertical Layout Group:
So when button 1 is pressed text one is shown:
And when the second button is pressed, a longer text is displayed and the scroll bar change:
So my advice would be to look at the ScrollView Element and not make a manual scroll inside a panel.
If I didn't understand your question right, please clarify your question and I'll be happy to help.