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 palalopea · Jan 08, 2018 at 04:07 PM · arraymatrix

how to create array with grid layout group

i want to create matrix 4 x n with List<> how to create array for it? and i have 4 strings into List. please help me :'(

Comment
Add comment · Show 2
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 osybear · Jan 08, 2018 at 04:15 PM 0
Share

Can you explain in more detail. I am a little confused on what you are trying to do.

avatar image TreyH · Jan 08, 2018 at 04:27 PM 0
Share

Can you clarify your problem? Are you showing the strings on your grid UI and need to store them somewhere?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by OneCept-Games · Jan 08, 2018 at 04:51 PM

Lists can contain a struct, so create a struct with 4 equal objects, and use the struct in the List type.

Comment
Add comment · Show 3 · 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 palalopea · Jan 08, 2018 at 06:59 PM 0
Share

if its integer/ double, i want to calculate the value into grid. I have this in c# VS:

 bool flag = true;
             double tmp;
             for (int i = 1; (i < Listbuilding.RowCount-1) && flag; i++)
             {
                 flag = false;
                 for (int j = 0; j < Listbuidling.RowCount-1; j++)
                 {
                     if (_saw[0, j + 1] > _saw[0, j])
                     {
                         tmp = _saw[0, j];
                         _saw[0, j] = _saw[0, j + 1];
                         _saw[0, j + 1] = tmp;
                         tmp = _saw[1, j];
                         _saw[1, j] = _saw[1, j + 1];
                         _saw[1, j + 1] = tmp;
                         flag = true;
                     }
                 }
             }

how its in unity? *sorry I'm still newbie

avatar image OneCept-Games palalopea · Jan 08, 2018 at 08:52 PM 0
Share

Your code seem to be C already, so not much difference in Unity Script/C#.
Your Listbuidling i assume is an Array, so RowCount would be Length ins$$anonymous$$d.
_saw in your case would just be Listbuidling[], unless you try to transfer Listbudling to _saw, where you could just use Array.Clone().
If you want to cast doubles to integers you just use the cast syntax, like: tmp = (double)_saw[];
Hope it brings you further, but i need more context, if you need more detailed answer.

avatar image palalopea OneCept-Games · Jan 09, 2018 at 08:33 AM 0
Share

I want to create Simple Additive Weighting (SAW) method, and this is my code :

 private DB _dbctrl = new DB();
 private List<ListBuilding> Listbuilding = new List<ListBuilding>();
  public double[] _Capacity, _Rooms, _Equipment, _Parking;
             public double[,] _saw;
 
 
 void normalization()
             {
                 int row = Listbuilding.RowCount;
                 _Capacity = new double[row];
                 _Rooms = new double[row];
                 _Equipment = new double[row];
                 _Parking = new double[row];
                
                 double maxCapacity =0, maxRooms = 0, maxEquipment = 0, maxParking = 0; 
             
               // i want to get data from sqlite
                 for (int i=0; i<row;i++)
                 {
                     _Capacity[i] = (double)Listbuilding.Rows[i].Cells["CAPACITY"].Value;
                     _Rooms[i] = (double)Listbuilding.Rows[i].Cells["ROO$$anonymous$$S"].Value;
                     _Equipment[i] = (double)Listbuilding.Rows[i].Cells["EQUIP$$anonymous$$ENT"].Value;
                     _Parking[i] = (double)Listbuilding.Rows[i].Cells["PAR$$anonymous$$ING"].Value;
                     
                    
                     if(i==0)
                     {
                        
                         maxCapacity = _Capacity[i];
                         maxRooms = _Rooms[i];
                         maxEquipment = _Equipment[i];
                         maxParking = _Parking[i];
                         
                     }
                     else
                     {
                         
                         if (maxCapacity < _Capacity[i])
                             maxCapacity = _Capacity[i];
                         
                         if (maxRooms < _Rooms[i])
                             maxRooms = _Rooms[i];
                        
                         if (maxEquipment < _Equipment[i])
                             maxEquipment = _Equipment[i];
                         if (maxParking < _Parking[i])
                             maxParking = _Parking[i];
                         
                         
                     }
                 }
                 for (int i = 0; i < row; i++)
                 {
     
                     _Capacity[i] /= maxCapacity;
                     _Rooms[i] /= maxRooms;
                     _Equipment[i] /= maxEquipment;
                     _Parking[i] /= maxParking;
                    
                    
                 }
             }
      private void button1_Click(object sender, EventArgs e)
             {
                 dataGridView1.Columns.Clear();
                 normalization();
                 _saw = new double[2,Listbuilding.RowCount];
                 double w_capacity, w_rooms, w_equipment, w_parking;
                 w_capacity = double.Parse(valcapacity.Text);
                 w_rooms = double.Parse(valrooms.Text);
                 w_equipment = double.Parse(valequipment.Text);
                 w_parking= double.Parse(valparking.Text);
                
                 double sumWeight = w_parking + w_rooms + w_capacity + w_equipment;
                 
             // initialization weights
                 if (w_capacity== 0)
                     w_capacity = 0.001;
                 else
                     w_capacity /= sumWeight;
                 
                 if (w_rooms == 0)
                     w_rooms = 0.001;
                 else
                     w_rooms /= sumWeight;
                 
                          
                 if (w_equipment == 0)
                     w_equipment = 0.001;
                 else
                     w_equipment /= sumWeight;
                 if (w_parking == 0)
                     w_parking = 0.001;
                 else
                     w_parking /= sumWeight;
                
                
      // saw method
                 for (int i = 0; i < Listbuilding.RowCount; i++)
                 {
                     
                     _saw[0,i] = (_Parking[i] * w_parking) + (_Rooms[i] * w_rooms) +  (_Capacity[i] * w_capacity) +(_Equipment[i] * w_equipment);
                     _saw[1, i] = i;
                     //dataGridView1.ColumnCount = 2;
                     //dataGridView1.Rows.Add(_saw[1,i], _saw[0,i]);
                 }
                 bool flag = true;
                 double tmp;
                 for (int i = 1; (i < Listbuilding.RowCount-1) && flag; i++)
                 {
                     flag = false;
                     for (int j = 0; j < Listbuilding.RowCount-1; j++)
                     {
                         if (_saw[0, j + 1] > _saw[0, j])
                         {
                             tmp = _saw[0, j];
                             _saw[0, j] = _saw[0, j + 1];
                             _saw[0, j + 1] = tmp;
                             tmp = _saw[1, j];
                             _saw[1, j] = _saw[1, j + 1];
                             _saw[1, j + 1] = tmp;
                             flag = true;
                         }
                     }
                 }
                 
                 double column1,column2,column3,column4;
                 
                 for (int i = 0; i < 5; i++)
                 {
                     int index = (int)_saw[1,i];
                     dataGridView1.ColumnCount = 4;
                     dataGridView1.Columns[0].HeaderText = "CAPACITY";
                     dataGridView1.Columns[1].HeaderText = "ROO$$anonymous$$S";
                     dataGridView1.Columns[2].HeaderText = "EQUIP$$anonymous$$ENT";
                     dataGridView1.Columns[3].HeaderText = "PAR$$anonymous$$ING";
                 
                     column1 = (double)Listbuilding.Rows[indeks].Cells["CAPACITY"].Value;
                     column2 = (double)Listbuilding.Rows[indeks].Cells["ROO$$anonymous$$S"].Value;
                    
                     column3 = (double)Listbuilding.Rows[indeks].Cells["EQUIP$$anonymous$$ENT"].Value;
                    column4 = (double)Listbuilding.Rows[indeks].Cells["PAR$$anonymous$$ING"].Value;
                     dataGridView1.Rows.Add(column1,column2,column3,column4);
                     //dataGridView1.ColumnCount = 2;
                     //dataGridView1.Rows.Add(_saw[1,i], _saw[0,i]);
                 }
             }

I use datagridview for my list data, but I wanna use grid layout group in unity and get the data from sqlite. but I don't know to do it :( very grateful if you can help me, friend. thanks

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

86 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

Related Questions

Javascript array questions. 1 Answer

Recursive Tree Loop? How do i make the matrix-array? 3 Answers

As I compare 4 objects in an array? 2 Answers

IndexOutOfRangeException: Array index is out of range. 1 Answer

How destroy a object and it's similars 4 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