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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Pauls · Feb 14, 2013 at 03:01 PM · rendererplanehiderenderer.enabled

hide different planes, renderers issue

Hi,

i would like to create an animated texture, i would like to create 15 planes, add a texture to each of them, and hide them one after the other to fake the animation. This code does not work because it says "NullReferenceException: Object reference not set to an instance of an object", i have put 2 planes with a mesh renderer (set automatically) in an empty object named "AT", then i created a script linked to the camera, or to the AT object (in this case, i changed "at" with "this" ) :

 //private var at : GameObject;
 private var renderers : Renderer[];
 
 function Start () {
     //at = GameObject.Find("AT");
     //renderers = at.GetComponentsInChildren(Renderer);
     //renderers = GetComponentsInChildren(Renderer);
     renderers = this.GetComponentsInChildren(Renderer);
 }
 
 function Update () {
 
     for (var r : Renderer in renderers) { /*  NullReferenceException  */
         r.enabled = !r.enabled;
     }
     
 }


Would you know how to achieve this?

Thanks

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
0

Answer by robertbu · Feb 14, 2013 at 04:26 PM

If you are trying to "fake" an animation, you can create a single plane and change the texture on that plane. There is some source here:

http://answers.unity3d.com/questions/392517/introduction-movie.html

As for your code above, did you check to see if 'renderers' is null?

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 Pauls · Feb 14, 2013 at 04:43 PM 0
Share

thanks, each image has a 512x512 resolution, and i have 15 frames + 20 frames (a second animated texture), i think this will add a lot of draw calls if i don't use a texture atlas, but can i use a texture atlas with so many textures? This is why i headed to the planes (all the planes in a single object so that i can use 1 draw call with a script) 2/ how could i cast it? i tried "length" but it says "InvalidCastException: Cannot cast from source type to destination type."

avatar image robertbu · Feb 15, 2013 at 12:54 AM 0
Share

The code above will only generate one draw call since only one texture is displayed in any one frame.

The limit to a texture atlas is not number of "subtextures," but total size. It can have any number of object as long as they fit on the texture. For an iPad the maximum atlas size is 4$$anonymous$$ x 4$$anonymous$$, so it could contain up to 64 of your 512 x 512 images.

We use EZGUI for our interface work, and their PackedSprite class would allow you to simply drag your textures into their Timeline editor and your animation would be done. But the code above will do the job.

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

9 People are following this question.

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

Related Questions

Changing two different objects renderer colour 1 Answer

How do I make different gameobjects appear, every time you click the GUI.button? 2 Answers

Unity 2019.4.9f1 - Toggle Show/Hide Gameobject with one keystroke. 1 Answer

Object being covered by a plane below it 0 Answers

Duplicate everything in a set space in all directions? 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