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
0
Question by menof36go · Jun 20, 2016 at 08:53 PM · c#unity 5arraymultiplayermultidimensional array

Are multidimensional arrays supported in UNET?

Ive run into some strange behaviour writing my inventory system.

An integer array with a total length of 48, first dimension being 24 indexes long and second dimension being 2 indexes long, became an array with a total length of 48, 48 first dimension, 0 second dimension. This lead to some frustrating problems, since I couldnt find any documentation about it and kept getting null reference exceptions trying to access an element using multiple indexes on a now one dimensional array. Did I miss something or am I doing something wrong?

This only seems to happen using UNET.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Orami · Jun 20, 2016 at 10:01 PM

Yes, they should be supported as long as you are using native types. If it is causing an issue you could always do something like:

inventory[x+(y*24)] which would make it to your inventory[24][2] layout...

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 menof36go · Jun 21, 2016 at 07:08 PM 0
Share

Is an integer a "native type"? (Never heard of those before, are those the same as primitives?) If it is it should work, but since it doesnt its either my code thats not working or you are wrong (no offence). Can you give me any evidence or documentation backing your post up? Again, I dont want to offend you, but its really hard to differientiate between false statements and actual solutions on the internet. How is inventory[x+(y*24)] supposed to work btw? I dont get how that would make it to my layout, please explain. I am trying to create my own workaround right now, but since I havent found a real solution yet i still hope you can help.

avatar image Orami menof36go · Jun 21, 2016 at 10:09 PM 0
Share

int, float, char, string, double. I probably thought primitive, but typed native. You can't sync an enum, but you can sync a struct or a class if it contains only those primitive types.

 [Serializable]
 public class BaseCharacterInfo   //syncs ok
 {
     public int STR;
     public int INT;
     public int WIS;
     public int DEX;
     public int CON;
 
     public int allocPoints;
 
     public int HP;
     public int xHP;
 }

 [Serializable]
 public struct Spell  //will not sync
 {
     public string name;
     public GameObject go;
     public spellType Type;
 }

Why it works: I assume you have 2 rows each with 24 elements. So each row has 0...23 elements.

Here is a 2d array in an image this might be more help than me trying to type out a long explanation (having issues using the image insert... give me a moment here is a link)

https://postimg.org/image/iiwg9ac4h/

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Unet assigning local player Authority to a gameObject. 1 Answer

Store multiple sprite in code C# 0 Answers

Change color of the object based on previous player's choice 0 Answers

Multiple Cars not working 1 Answer

Array foreach problem 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