Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Marynancy · Oct 11, 2019 at 11:12 AM · table

Table with rows and columns editable

Hi.. I am trying to create 3*3 table where the data in the table is editable in editor window. Is there a specific way to create such. please help me

Comment
Add comment · Show 1
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 Marynancy · Oct 11, 2019 at 11:32 AM 0
Share

@$$anonymous$$aspianR , Am trying to accomplish this in Editor window so when I see in game window the table should have data in rows and columns

1 Reply

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

Answer by KaspianR · Oct 11, 2019 at 12:32 PM

Okay @Marynancy! Sorry for the delay, some things popped up. I almost understood that you meant the editor window so I removed the initial comment but thanks for the verification. I wrote a small script for you that I hope will work:

 string[,] CreateTable(string[,] table)
 {
     for (int y = 0; y < table.GetLength(0); y++)
     {
         float width = Screen.width - 16;
         GUILayout.BeginHorizontal();
         for (int x = 0; x < table.GetLength(1); x++)
         {
             table[y, x] = GUILayout.TextField(table[y, x], GUILayout.Width(width / table.GetLength(1)));
         }
         GUILayout.EndHorizontal();
     }
     return table;
 }

And then just call it using:

 [YourTable] = CreateTable([YourTable]);

[YourTable] should be a two dimensional string-array and then this function should be flexible and size correctly! Hope it works our for you and sorry for the delay!

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 Bunny83 · Oct 11, 2019 at 02:24 PM 0
Share

It's kinda pointless to return the same array you pass in as you modify the inco$$anonymous$$g array anyways. Also using multidimensional arrays might not be that useful in the context of Unity since Untiy can not serialize multi dim arrays and they also tend to be slower than a manually flattended array or an array of a class that contains a nested array. Those two solutions could be serialized by unity (as long as the nested class is marked as serializable and the actual contained type is serializable by Unity).

avatar image KaspianR Bunny83 · Oct 14, 2019 at 09:11 AM 0
Share

@Bunny83 I get your point although I don’t really agree. The serializable would totally be a problem for most uses but in this case I wrote a way to serialize it so in this specific case I think it should be fine. $$anonymous$$odifying the code to make work with an object wouldn’t be all that hard though and if $$anonymous$$arynancy would prefer that he’s welcome to do so. About the sending back the same variable but modified I see your point and I agree. For most uses a reference or similar would be better but in this case I didn’t since it looks more like the other EditorGUI methods this way. A pretty dull reason I know but I just like it more this way! :D

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

113 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 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 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 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 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

For in a hash table 1 Answer

How could I store negative coordinates with negative indexes with C#? 1 Answer

How will i update my table values every time? 1 Answer

Yield return tables selectable with mysql data 0 Answers

Storing game information in Array 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