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
0
Question by sdgd · Feb 26, 2013 at 11:29 AM · c#arraycs0246passthrough

is it possible to give only part of array through []

what I'm trying to do is not creating loads and loads of arrays but 1 BIG array and separate it by numbers so to say

my structure

 using UnityEngine;
 using System.Collections;
 
 public struct ExpandRect {
     public void ExpandF(Rect FirstRect, ref Rect[] Expandable, ref float LastRectY){
         int i=0 ;
         for (; i<Expandable.Length; i++) {
             Expandable[i] = new Rect (FirstRect.x + FirstRect.width,  (FirstRect.y + Expandable[i].height * i)  ,Expandable[i].width, Expandable[i].height);
         }
         LastRectY = Expandable[i].y + Expandable[i].height;
     }
 }


and I'm calling the structure

 public Rect[] SkillButtonRec = new Rect[200];
 
 public float SHeight = 20 ;
 public float SWidth = 50 ;
 
 public ExpandRect ExpaRec;
 
 float lastpos = 0;
 
         ExpaRec.ExpandF(new Rect(0,0,SWidth,SHeight), ref SkillButtonRec[1 - 3], ref lastpos);
         
         if (SkillNameb[0] = GUI.Toggle((SkillButtonRec[0] = new Rect(0,0,SWidth,SHeight)) ,SkillNameb[0], SkillName[0] )){
 //            GUI.Toggle(SkillNameb[1], SkillName[1]);
 //            GUI.Toggle(SkillNameb[2], SkillName[2]);
 //            GUI.Toggle(SkillNameb[3], SkillName[3]);



this:

 Rect(0,0,SWidth,SHeight), ref **SkillButtonRec[1 - 3]**, ref lastpos);

is what I'm trying to achive is it possible or I must create loads of arrays and call give them whole afterwords?

thanks in advance

yes I know I could use 50 times begin horizontal and begin vertical but that gives me headache especially for so complicated gui I want to have this 1 step is easy to make with that but doing it 30 of them is different story

Comment
Add comment · Show 4
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 GuyTidhar · Feb 26, 2013 at 11:35 AM 0
Share

why not add the start and end index you which to expend as arguments?

avatar image sdgd · Feb 26, 2013 at 11:37 AM 0
Share

am what do you mean?

how would I do that to array?

avatar image GuyTidhar · Feb 26, 2013 at 11:48 AM 0
Share

Check out the answer I posted.

avatar image sdgd · Feb 26, 2013 at 11:55 AM 0
Share

yeah that could do the trick good idea thanks

1 Reply

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

Answer by GuyTidhar · Feb 26, 2013 at 11:47 AM

 public void ExpandF(Rect FirstRect, ref Rect[] Expandable, ref float LastRectY, int start, int end)
 {
   for (int i=start; i<=end; i++) 
   {
       Expandable[i] = new Rect (FirstRect.x + FirstRect.width,  (FirstRect.y + Expandable[i].height * i)  ,Expandable[i].width, Expandable[i].height);
   }
   LastRectY = Expandable[i].y + Expandable[i].height;
 }

And then when you call it, you'd do:

 Rect(0,0,SWidth,SHeight), ref SkillButtonRec, ref lastpos, 1, 3);

By the way, you don't need to use 'ref' when passing objects (non value types) - they are already passed as reference.

an array is always a reference type. float for instance is a value type.

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 sdgd · Feb 26, 2013 at 11:57 AM 0
Share

yeah OFC thanks forgot it's already referenced

it completely came in to my sub conscious so I don't need to write too long codes

avatar image GuyTidhar · Feb 26, 2013 at 12:01 PM 0
Share

N.P!

Glad it helped.

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

10 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to set a specific gameobject in an array false when it collides with a trigger. 1 Answer

C# print Array? 1 Answer

Question about FindObjectsOfType 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