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
5
Question by Mezcaholic · Jan 17, 2013 at 12:43 AM · c#unity 4mono

Does Unity 4 Mono support Tuples?

Does the Mono that ships with Unity 4 support Tuples? Mono is 2.6, I have not found a definitive answer online. Is anyone using Tuples with Unity 4?

Thanks, -E

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

4 Replies

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

Answer by zharramadar · Feb 18, 2013 at 07:12 PM

No, Unity does not support Tuples. Maybe when Unity upgrades its Mono version to support features that came in .NET Framework 4.

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 illustir · Oct 14, 2015 at 01:07 PM 0
Share

Really!!?!? Just a continuous disappointment this.

avatar image
4

Answer by ShawnFeatherly · Jan 26, 2014 at 02:55 AM

Doesn't seem available in the Unity 4.3 either. But you can always include your own copy of Tuple.cs: https://gist.github.com/michaelbartnett/5652076

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
avatar image
3
Wiki

Answer by VertexSoup · Jan 21, 2015 at 01:44 AM

Something like this may help you or use ShawnFeatherly premade classes:

 public class Tuple<T1, T2>
 {
     public T1 First { get; private set; }
     public T2 Second { get; private set; }
     internal Tuple(T1 first, T2 second)
     {
         First = first;
         Second = second;
     }
 }
 
 public static class Tuple
 {
     public static Tuple<T1, T2> New<T1, T2>(T1 first, T2 second)
     {
         var tuple = new Tuple<T1, T2>(first, second);
         return tuple;
     }
 }
Comment
Add comment · Show 2 · 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 longbowgr · Jun 01, 2015 at 11:32 AM 1
Share

A tuple of two is called a Pair, so that the class would be better if it was named Pair.

avatar image kalibcrone longbowgr · Aug 07, 2017 at 02:37 PM 0
Share
  public class Tuple<T1, T2, T3>
     {
         public T1 First { get; private set; }
         public T2 Second { get; private set; }
         public T3 Third { get; private set; }
         internal Tuple(T1 first, T2 second, T3 third)
         {
             First = first;
             Second = second;
             Third = third;
         }
     }
     
     public static class Tuple
     {
         public static Tuple<T1, T2, T3> New<T1, T2, T3>(T1 first, T2 second, T3 third)
         {
             var tuple = new Tuple<T1, T2, T3>(first, second, third);
             return tuple;
         }
     }



avatar image
0

Answer by VitruvianStickFigure · Dec 30, 2017 at 08:38 PM

These are great responses; though sometimes when I'm trying to keep my project tidy, I'll work with out parameters instead. For instance:

 Vector3 v = ...;
 Tuple<int, int, int> c = ConvertToInts(v);

would become

 Vector3 v = ...;
 int x, y, z;
 ConvertToInts(v, out x, out y, out z);

This obviously doesn't do everything that Tuples are around for, and you can't use it on a property; but it's helped me skirt around the problem multiple select times in the past.

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

14 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

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Rotate Camera 1 Answer

An OS design issue: File types associated with their appropriate programs 1 Answer

When will Unity Support .NET 4 to the current Mono Level? 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