Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 Tomza · Sep 28, 2014 at 12:28 AM · gameobjectmenuscroll

Scrolling GameObject in Unity3D

Most problems with computer programming I can solve alone, but sometimes it's hard to find a solution. And now I have such a problem.

Is there a possibility to write a script for game object scrolling? Just like textures. In other words, using objects like textures: scroll them and make a menu (when clicking, something happen). For example, we have seven 3D boxes (for every day of week) and we can scroll choosing one and the rest is faded at the same time. The chosen one can be highlighted in some way ( becomes bigger or lightened).

Comment
Add comment · Show 6
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 robertbu · Sep 28, 2014 at 03:39 AM 0
Share

Scrolling 3D objects is not hard, but I'm having trouble visualizing how it is scrolling and it relationship to other objects. This line in particular is confusing to me:

For example, we have seven 3D boxes (for every day of week) and we can scroll choosing one and the rest is faded at the same time.

What does 'scroll choosing one' mean, and what happens to the other days of the week when it is scrolling?

avatar image Tomza · Sep 28, 2014 at 05:18 AM 0
Share

There are seven boxes like a calendar (for a week). it's like a shelf. Every day of week can have its box so that we can put something in. if we choose one day, for example $$anonymous$$onday, the box for $$anonymous$$onday should be somehow highlighted, the rest days (boxes) should be faded. We can scroll horizontally the days using arrows and choose days.

The user can choose $$anonymous$$onday:

| $$anonymous$$onday| Tuesday | ... | Saturday | Sunday |

<------------------------------------------->

Scrolling

$$anonymous$$onday highlighted, all other days faded

Or Saturday:

| $$anonymous$$onday| Tuesday | ... | Saturday | Sunday |

<------------------------------------------->

Scrolling

Saturday highlighted, all other days faded

The user can choose days he/she wants. And the chosen day is highlighted and other days faded. That is game objects (boxes) faded.

This is a complicated task and hard to explain. Could you imagine seven boxes to choose for the users? And he/she can choose one at one time. And the box chosen by him/her is highlighted, all other faded. Then, he/she can choose other box: the previous chosen box will be faded and the chosen highlighted. Only one box is always highlighted, the rest of them faded.

avatar image robertbu · Sep 28, 2014 at 06:33 AM 0
Share

This question is not a good fit for Unity Answers. Unity Answers deals with single, specific technical problems. Your question has many separate technical issues, most of which have been covered a few times in the past. Break your question apart, experiment, and when you get stuck, post back with a specific questions. Here are some of the issues/tasks in your question:

  1. Select either Raycasting/Touch or On$$anonymous$$ouseDown() to handle input

  2. Drag and drop code...multiple different versions have been posted on Unity Answers and Unity Forums.

  3. Velocity and friction. $$anonymous$$ost people with this kind of interface expects to be able to swipe and have the list continue to scroll for a bit.

  4. Stops at the ends. Could be a simple clamp, but often people want it to bounce at the ends.

  5. Figure out Text/Label display (several choices listed below)

  6. Figure out selection method

  7. Given that most solutions involve colliders for individual labels, you have to figure out how to propagate swipe movements from the children.

  8. Figure out interface to export the selection.

Display methods

  • Using separate game objects with separate textures - simple but will result in 7, non-batched draw calls.

  • Use a single quad with seven (or possibly eight if there is a no-day selected state) textures representing each of the selection states.

  • Use seven quads and a sprite sheet for displaying the days. The sprite sheet would contain 14 'images'...a selected and un-selected state for each day of the week. The UVs in the mesh would be set to map in the correct 'image' from the sprite sheet. This is how commerical products like NGUI and EZGUI do it.

  • Build a single mesh with seven quads...one for each day of the week. A more complicated solution, but it has the highest efficiency and would simplify the drag code a bit.

avatar image Tomza · Sep 28, 2014 at 08:05 AM 0
Share

robertbu, you yourself complicated the problem. $$anonymous$$y question was: is it possible to scroll game objects? And maybe simple example. I know raycasting On$$anonymous$$ouseDown(), DragNDrop code, and many things you wrote. I have never seen such an example, even a simple one, so I'm asking. Why did you close my question? If you don't know or don't want to help, just do nothing.

avatar image robertbu · Sep 30, 2014 at 03:34 AM 0
Share

@$$anonymous$$aza - If you already know Drag and Drop, then to scroll basic scroll is just confining the drag to one axis. And yes there have been questions and answers about dragging confined to a single axis.

If you don't know or don't want to help, just do nothing.

I may not always get it right, but there are standards on this site that I'm increasingly trying to abide by. And I still think I got it right this time. Here is the core of your question quoted from you:

in other words, using objects like textures: scroll them and make a menu (when clicking, something happen).

This is not a single specific question, and you brought nothing to the table with respect to your own code, or how you were attempting the design. And I have implemented this functionality a couple of times, so I have a pretty good idea of some ways it can be done (and the pitfalls). What I was asking you to do is spend some time researching the various technical issues within your question and then ask single, specific questions.

Show more comments

1 Reply

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

Answer by Tomza · Jan 14, 2015 at 06:58 PM

The code for object scrolling.

 using UnityEngine;
 using System.Collections;
 
 public class ScrollNewProductsStatic : MonoBehaviour {
 
     public static int curWeapon;
     private int currentWeapon;
     public Transform[] weapons;
 
     // Use this for initialization
     void Start () {
         curWeapon = 0;
     }


     // Update is called once per frame
     void Update () {
         
         
         
         if(curWeapon == weapons.Length + 1){
             curWeapon = 0;
         }
         
         if(curWeapon == -1){
             curWeapon = 5;
         }
         
         changeWeapon(curWeapon);
         //Debug.Log("Static :" + curWeapon);
     }
     
     public void changeWeapon(int num) {
     
         currentWeapon = num;
         
         for(int i = 0; i < weapons.Length; i++) {
         
             if(i == num){
                 
                 weapons[i].gameObject.transform.localScale = new Vector3(2.0f,2.0f,2.0f);
                 
                 
                 }
                 
             else{
                 
                 weapons[i].gameObject.transform.localScale = new Vector3(1.0f,1.0f,1.0f);
                 
                 
                 }
     
             }
     }
     
     
 }


This script is for all 3D objects to be scrolled. I can be attached to the top of the Projector object hierarchy (name of the projector). Then you need to two other scripts for two arrows to scroll the objects.

The first arrow:

 using UnityEngine;
 using System.Collections;
 
 public class ScrollNewProductsLeft : MonoBehaviour {
 
     private int getScroll;
     private int newScrollM;
     
     // Use this for initialization
     void Start () {
         
         newScrollM = 0;
         
     }
     
     // Update is called once per frame
     void Update () {
     
     }
     
     void OnMouseDown(){
             
             ScrollNewProductsStatic.curWeapon++;
             
         }
 }


The second arrow:

 using UnityEngine;
 using System.Collections;
 
 public class ScrollNewProductsRight : MonoBehaviour {
 
     private int getScroll;
     private int newScrollA;
 
     // Use this for initialization
     void Start () {
 
         newScrollA = 0;
         
     }
     
     // Update is called once per frame
     void Update () {
     
     }
     
     void OnMouseDown(){
             
             ScrollNewProductsStatic.curWeapon--;
             
         }
 }



Apply one script to the first arrow and the other to the second.

Feel free to improve the scripts because I have no time. It's only an idea how to do that.

In this example, scrolling is just making the current object bigger, but you can use other effects.

Have a fun :)!

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

25 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 avatar image avatar image avatar image avatar image

Related Questions

individual object menu 0 Answers

UI Questions 1 Answer

Cube click pop-up menu 0 Answers

Updating Prefabs within other Prefabs (Nested) 1 Answer

button wont work in GUI.BeginScrollView 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges