• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by YuuShanderia · Apr 25, 2014 at 08:26 AM · guiviewscrollalternative

Alternative to GUI Scrollview ?

Hi guys,

I want to know if there is any other choices to create a scroll view aside from GUI Scrollview. The problem with GUI elements was that they displayed differently coordinates and size-wise between Unity and actual devices, which made my development process difficult. So, any suggestions ? Thanks a lot in advance !

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by YoungDeveloper · Apr 25, 2014 at 08:27 AM

Hi, you can create a GUI group, render everything inside it, and when "scrolling" just move GUI group y. What comes to screen independence, it's tricky, mostly you should use percentage instead of actual pixels, because or retina screens. You could use matrix, but its tends to stretch things..

 //Button which is 10% from horizontal sides
 private int screenXp;
 private Rect rect_button;
 
 private void Start(){
     screenXp = Screen.width/100;
     rect_button = new Rect(screenXp * 10,
                            0,
                            Screen.width - screenXp * 20,
                            Screen.height);
 }
 
 private void OnGUI(){
     GUI.Button(rect_button, ""); //same button on all devices, by not considering the ratio
 }
Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image YuuShanderia · Apr 25, 2014 at 04:54 PM 0
Share

Thank you for the answer ! What if just like the GUI scroll view, I want the scroll area to be just a small section within the screen, how could that be achieved using your method ? And what do you mean by "GUI group" ?

avatar image YoungDeveloper · Apr 25, 2014 at 05:33 PM 0
Share

Hi, if you want invisible wall effect, when scroll content "hides" after certain point, you will have to use scrollview. For gui group https://docs.unity3d.com/Documentation/ScriptReference/GUI.BeginGroup.html Everything inside group will be binded to its coordinate system.

avatar image YuuShanderia · Apr 26, 2014 at 02:56 AM 0
Share

Thank you ! Even though there's still some problems not resolved yet, now I have more choices to consider.

avatar image Bunny83 · Apr 26, 2014 at 03:19 AM 0
Share

Actually the ScrollView follows some strict rules and actually just pushed a GUIClip to the stack and passes the offset parameters. A GUI-Group does the same thing but you can't specify a client area offset. With two GUI-groups you can simulate what the ScrollView does. I've made auch a CustomScrollview some years ago for another UA question. This was only to completely hide the scrollbars and just provide scrolling without visible handle(s).

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GUI Scroll View 1 Answer

Problem with modifying scrollPosition on android 1 Answer

Disabling mouse wheel when user is scrolling ScrollView 3 Answers

Scroll bar not showing up? 0 Answers

Clickable Scrollable List? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges