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 /
This post is currently awaiting moderation. If you believe this to be in error, contact a system administrator.
This question was closed Mar 14, 2019 at 04:16 PM by TreyH.
avatar image
0
Question by Irenemeyer · Mar 13, 2019 at 04:29 PM · scripting probleminspector2d array

Getting data from a 2d array in Inspector

Hi,

I have a matrix in my GameObject Inspector and I need to access it from another script.
Script to build the Inspector ManholHealth : MonoBehaviour

 [Header("Health")]
 public Image healthBar;
 public Text probabPerc;
 public AgingObjects[] colors ;...

 [System.Serializable]
 public class AgingObjects
 {
     public Color healtColor = new Color();
     public float[] Prob ;
 }

}

Result:
alt text

What I need is to get the values in the elements of "prob".

Sorry, this is maybe a newbie question, but I am one.

screenshot-2019-03-13-at-162639.png (74.3 kB)
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 TreyH · Mar 14, 2019 at 04:16 PM 0
Share

Questions about accessing script properties from other objects / scripts have been covered pretty exhaustively. If you have a more specific question, then feel free to ask that ins$$anonymous$$d.

2 Replies

  • Sort: 
avatar image
0

Answer by xxmariofer · Mar 13, 2019 at 04:38 PM

 float value = manHolHealthInstance.colors[0].prob[indexOfTheElement];//just change 0 and indexofelement for the index of the objects you want to access
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
0

Answer by Irenemeyer · Mar 14, 2019 at 04:04 PM

@xxmariofer Thank you, but now the next problem, I'm trying to build a matrix like the one below, and I think I managed somehow, but if I try to print it to the console to check it, it doesn't work. Whatever combination I try it comes with the same error. Is there another way to print 2d lists?



//transition matrix
// P[1]= {0.998,0.001,0.0005,0.0005,0.00};
// P[2]= {0.00,0.995,0.003,0.001,0.001};
// P[3]= {0.00,0.00,0.995,0.0025,0.0025};
// P[4]= {0.00,0.00,0.00,0.99,0.01};
// P[5]= {0.00,0.00,0.00,0.00,1.00};

  for(int j = 0; j<= manholeScript.colors.Length-1; j++)
         {
             for (int i = 0; i <= manholeScript.colors[j].Prob.Length - 1; i++)
             {
                 float value = manholeScript.colors[j].Prob[i];
                 p.Add(value);
                 //foreach (float data in p)
                 //{
                 //    Debug.Log(data);
                 //}
             }
 
             P.Add(p);
                                 
         }
         foreach (float[,] data in P) Error: Cannot convert type 'System.Collections.Generic.List<float>' to 'float[*,*]'
         {
             Debug.Log(data);
         }
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

Follow this Question

Answers Answers and Comments

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

Arrays/Lists in the inspector of Editor Extension scripts 0 Answers

Add a new script line to my script with text from textboxes after button in the Inspector is pressed 0 Answers

There is no GameObject attached to this GameObject 2 Answers

Script reference not showing in inspector 0 Answers

Loop problem 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