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 Uriel_96 · Feb 03, 2011 at 11:44 PM · javascriptarraylistvariable

How to find the opposite variables list?

OK, I want to know how would be a script describing the opposite variables list like this example:

list_nums[0]=1;
list_nums[1]=2;
list_nums[2]=3;
list_nums[3]=4;
list_nums[4]=5;
useful_var[0] = 3;
useful_var[1] = 4;

and with this information that says the list of numbers is the number 5 and the useful variable are 3 and 4 I want to be able to know the opposite of the useful variable. In this case it would end something like this.

notuseful[0] = 1;
notuseful[1] = 2;
notuseful[2] = 5;

So what I want to know is how can I find the opposite of this variables.

Note: I am trying to do this to have like it says 1 and 2 so if you press 1 and 2 is correct but if you press 1,2 and 3 is wrong.

Thanks... for future :P

Comment
Add comment · Show 3
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 DaveA · Feb 04, 2011 at 12:07 AM 0
Share

Which type of array are you using, Built-in or other? C# or JS?

avatar image Uriel_96 · Feb 04, 2011 at 01:05 AM 0
Share

javascript, it says in the tags :P

avatar image Jesse Anders · Feb 04, 2011 at 02:44 AM 0
Share

He didn't just ask what language you're using; he also asked what type of container you're using.

1 Reply

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

Answer by yoyo · Feb 04, 2011 at 12:42 AM

I'd use C# generic Lists ...

using System.Collections.Generic;

...

List<int> list_nums = new List<int>(); list_nums.Add(1); list_nums.Add(2); list_nums.Add(3); list_nums.Add(4); list_nums.Add(5);

List<int> useful_var = new List<int>(); useful_var.Add(3); useful_var.Add(4);

List<int> notuseful = new List<int>(); foreach (int num in list_nums) { if (!useful_var.Contains(num)) { notuseful.Add(num); } }

Comment
Add comment · Show 5 · 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 Uriel_96 · Feb 04, 2011 at 01:04 AM 0
Share

and you know how to do this for java script?

avatar image yoyo · Feb 04, 2011 at 01:19 AM 1
Share

Not sure, I'm a C# guy :-). If you can't use generics then this may just work by using System.Collections and removing the "" bits, then tidying up the syntax for javascript. Syntax info available in this answer ... http://answers.unity3d.com/questions/5507/what-are-the-syntax-differences-in-c-and-javascript

avatar image Uriel_96 · Feb 04, 2011 at 02:31 AM 0
Share

sorry, I really try it and it does not work maybe because I was expecting another thing. I was asking for a way to find the variables you don't need and add it to the variable, I wasn't planning to use Hashtable methods:(, but thanks maybe this will help to much people but not for me. :P

avatar image Jesse Anders · Feb 04, 2011 at 02:48 AM 1
Share

yoyo's example code does exactly what you asked for. Is there any particular reason it doesn't meet your needs?

avatar image Uriel_96 · Feb 04, 2011 at 03:51 AM 0
Share

well maybe you haven't seen the note that I put in the question, that is actually what I am trying to do.

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

No one has followed this question yet.

Related Questions

Set variable/Array to a length by scripting 2 Answers

Setting Scroll View Width GUILayout 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

instantiate problem help? 1 Answer

On Button press Move Value toward 2 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