Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 michu86 · Apr 12, 2011 at 10:19 AM · changegui-buttonselect

select car in garage

how to do such a thing as I press the NEXT appears to me to be the next car http://img846.imageshack.us/i/garagee.jpg/ perhaps by changing the camera but I do not know how to do it:(

and how do I choose one of these cars that it appeared on a new scene

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

2 Replies

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

Answer by Jean-Fabre · Apr 12, 2011 at 11:29 AM

Hi,

If you only need to have a different car poping up and replace the current one, then you don't need to animate or do any camera mixing stuff.

Simply maintain a list of all the cars you want to be visible and maintain a variable that knows which car is currently visible. So if you have 4 car, the current car at start would be car 0.

the user press next or previous:

 1 hide the current car ( car x )
 2 select the next or previous car in your list ( car x +- 1 )
 3 show that one.

Does that make sense?

I have built a very basic c# component that will give you a starting point. Nothing fancy and 100% full proof, but the basic idea is here. If you have problems, let me know.

1: Simply create a c# script, and name it GOSelector. Edit it and paste the code below

2: drop it on any gameobject

3: select the component in the inspector

4: Define the number of items you want to have in GOList

5: drag and drop each one of them onto each items of GOList

6: optionnaly set a location for where you want them GameObject to be located.

Run. and press the left and right arrows to show the next or previous GameObject.

using UnityEngine; using System.Collections; public class GOSelector : MonoBehaviour {

 public GameObject[] GOList;
 private int _currentID;

 public Transform GOLocationSpot;

 // Use this for initialization
 void Start () {

     // if GOLocation spot is not declare, will use our own transform instead.
     if (GOLocationSpot== null){
         GOLocationSpot = transform;
     }
     // start by hiding all
     foreach(GameObject _go in GOList){
         // we move it to the right location
         _go.transform.position = GOLocationSpot.position;
         // and we hide it for now.
         _go.active = false;
     }

     // now show the first
     ShowID(0);
 }

 // Update is called once per frame
 void Update () {


         if (Input.GetKeyDown(KeyCode.RightArrow)){
             ShowNext();
         }

         if (Input.GetKeyDown(KeyCode.LeftArrow)){
             ShowPrevious();
         }
 }

 void ShowNext(){
     ShowID(_currentID+1);
 }

 void ShowPrevious(){
     ShowID(_currentID-1);
 }

 void ShowID(int ID){

     if (ID>=GOList.Length){
         ID = 0;
     }else if (ID<0){
         ID = GOList.Length;
     }

     // hide the current
     GOList[_currentID].active = false;

     // now store the new ID as being the current
     _currentID = ID;
     GOList[_currentID].active = true;

 }// ShowID

}

Hope it helps,

Bye,

Jean

Comment
Add comment · Show 1 · 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 bflorin519 · Oct 24, 2020 at 06:59 AM 0
Share

Thanks for this great answer, but how can i use the selected car into another scene?

avatar image
0

Answer by michu86 · Apr 12, 2011 at 09:27 PM

Prefab GameObject's can not be made active! (CAMARO) UnityEngine.GameObject:set_active(Boolean)????

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

1 Person is following this question.

avatar image

Related Questions

Deselect a selected object? 2 Answers

I need a command to select and change a single object 2 Answers

How to change texture on parts of terrain 3 Answers

Can I customize the resolution window that appears at the start of my executable? 2 Answers

Change Name Of Prefab That Initiates 1 Answer


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