Created
February 14, 2012 20:09
-
-
Save aras-p/1829848 to your computer and use it in GitHub Desktop.
cache instead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static public void SetRenderActiveFlagMode( ref GameObject parent, bool mode ) | |
| { | |
| var pr = parent.renderer; // query the component just once! | |
| if( pr != null ) | |
| { | |
| pr.enabled = mode; | |
| } | |
| var pt = parent.transform; // query the component just once! | |
| int childCount = pt.GetChildCount(); | |
| for(int i = 0; i < childCount ; i++) | |
| { | |
| var pc = pt.GetChild(i); // query the child just once! | |
| Renderer rr = pc.renderer; | |
| if( rr != null ) | |
| { | |
| rr.enabled = mode; | |
| } | |
| GameObject go = pc.gameObject; | |
| if( go != null ) | |
| { | |
| SetRenderActiveFlagMode( ref go , mode ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment