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 elmidiachi · Jan 09, 2017 at 08:34 AM · c#iosgetcomponentarraysrenderer

Enable MeshRenderer from all objects in array

Hello everyone,

I've been searching for a solution for my problem on the web, and posted this question about it, but as far as I tried now, there aren't any solutions yet. I have an array of gameobjects colorStamps, with their Meshrenderers disabled by default. When my player gets a specific pickup, the "ShowPath()" function is being called and the MeshRenderers from all the colorStamp gameobjects in the array should enable. In the Unity Editor it works like a charm, but when I build to iOS, the meshes don't show/ stay disabled.

Code (CSharp):

public void ShowPath() { colorStamps = GameObject.FindGameObjectsWithTag("PathBlocks");

     for (int i = 0; i < colorStamps.Length; i++)
     {
        TheMesh = colorStamps[i].gameObject.GetComponent<MeshRenderer>() as MeshRenderer;
         TheMesh.enabled = true;
     }

I've read that the GetComponent could return a component, instead of an MeshRenderer, so I already tried the 'as MeshRenderer' at the end of the declaration line. I tried with and without. Also, I've read that in iOS, the 'shortcut' for GetComponent().enable could give problems, but separating them didn't fix it either. Last but not least, yes, the colorStamps objects are tagged with the PathBlocks tag and the colorStamps GameObject[] is declared on top of the script. Plus, yeah, it does work in the editor, so it has to be something in the conversion to iOS? What am I doing wrong? Thanks for your help!

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
2
Best Answer

Answer by sameel · Jan 09, 2017 at 08:41 AM

@elmidiachi, Use this instead.

 for (int i = 0; i < colorStamps.Length; i++)
      {
          colorStamps[i].gameObject.GetComponent<MeshRenderer>().enabled = true;
      }
Comment
Add comment · Show 8 · 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 elmidiachi · Jan 09, 2017 at 12:52 PM 0
Share

Thanks for your reply. That was the first option I tried. But it doesn't work on iOS. Still working in the Unity Editor...

avatar image sameel elmidiachi · Jan 09, 2017 at 01:07 PM 0
Share

If its working in unity editor then it should work on ios iOs too.

avatar image elmidiachi sameel · Jan 09, 2017 at 01:26 PM 0
Share

yeah! That's what I thought... But nope. The meshes aren't being enabled after the pickUp. Strange eh? I'm building to iOS on my i$$anonymous$$ac, using Xcode 8.2.1 and running on iOS 10.2, iPhone 7.

Show more comments
avatar image elmidiachi · Jan 12, 2017 at 10:22 AM 0
Share

No solution yet :( I made a new comment, But its still in moderation. Thanks already though!

avatar image sameel elmidiachi · Jan 12, 2017 at 05:41 PM 1
Share

try this

avatar image elmidiachi sameel · Jan 12, 2017 at 10:01 PM 0
Share

@sameel!! thank you sooo much! I really don't understand what was going on. I created a new prefab from the original object and now it works in the editor and in iOS!! This is really weird... But hell yes, it works :) Thanks for your help and finding that post!

Show more comments

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

EDITED rend.material change too hard to handle for iOS 0 Answers

Multiple Cars not working 1 Answer

An object reference is required to access non-static member `UnityEngine.Component.GetComponent(System.Type) 1 Answer

Distribute terrain in zones 3 Answers

[SOLVED] How to make a mesh with mobile/bumped diffuse shader transparent? 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