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 N1warhead · Oct 15, 2014 at 11:53 AM · optimizationmemoryrendermesh renderer

Mesh Renderer and Memory

Hey guys, I've been searching a couple days now, I can't find a definitive answer on this.

But if I disable the renderer does it not load the object into memory until it's turned back on?

I know it works with Draw Calls and stuff, but nothing has exactly answered if it's already preloaded into memory. (Making a massive online game) that's why I'm asking.

That way I can optimize as I build so I don't have to go back to it later.

Thanks in advance guys!

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

2 Replies

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

Answer by tanoshimi · Oct 15, 2014 at 12:06 PM

Disabling the renderer of an object merely means that it won't be drawn. Any scripts attached to the object will continue to run, as will collisions and any physics calculations affecting the object etc. So, yes, it's very much still in "memory".

Comment
Add comment · Show 13 · 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 N1warhead · Oct 15, 2014 at 12:11 PM 0
Share

I'm still going to mark this as Correct because I believe you, just wasn't sure.

So okay then, that leads me to another question on the same subject, is there any way to ("Deload") and object and only load it when the player is close enough. No sense in having something there that don't need to be there yet.

avatar image HarshadK · Oct 15, 2014 at 12:12 PM 1
Share

@tanoshimi you ninja'd me while I was busy writing a long response to prove it. ;-)

avatar image HarshadK · Oct 15, 2014 at 01:09 PM 1
Share

Thanks @tanoshimi and @N1warhead

You can use Instantiate in this case also. You can also use Resources.Load to load resources only when they are required and can Unload them when they are not required.

If possible you can also reuse the same objects like you have enemy A at point #1 then you can teleport the same enemy A to other end of the map say point #2 when player reaches there. In this case you can store the state for that enemy at point #1 so that when player again reaches point #1 you can set this saved state for your enemy A to make him that same enemy at point #1. This is only applicable if it is the same enemy.

If there are two different enemies then loading them at runtime is the option you have.

avatar image HarshadK · Oct 15, 2014 at 01:31 PM 1
Share

If I goto enemy, - $$anonymous$$ILL HI$$anonymous$$ lol. - don't really destroy it, just make it move to another end of the map, therefore saving networking overloading lol?

  • Yes.

avatar image N1warhead · Oct 15, 2014 at 01:58 PM 1
Share

I agree.

It's going to be very difficult, but hey if you ever want even a AA quality game you have to put a lot of hard work in to it..

I'm making massive open world environments where you hunt dinosaurs. I'm not talking about like Carnivores game, I'm talking better.

I want to make the Dinosaurs travel in heards, eat other dinosaurs, sleep, fight for leader of their packs, communicate, hear you, get mad, get scared, and so forth. I have experience program$$anonymous$$g Artificial Neural Networks, so I should be able to do it, that is if Unity is like other languages at least.

It's going to get as real as real can get I guess lol...

But there really isn't any story to it, just either single player or online hunting with people around the world lol.

Show more comments
avatar image
2

Answer by HarshadK · Oct 15, 2014 at 12:11 PM

It is loaded in the memory since mesh renderer is one component that is not active but others are like say colllider or rigidbody, which are still taking part in the scene.

And these other components need to perform their job even if mesh renderer is active or not. If the mesh renderer is not active then only the rendering part is not performed but other are.

Here's a small script to check this thing:

 using UnityEngine;
 using System.Collections;
 
 public class MeshRendererTest : MonoBehaviour {
 
     // Update is called once per frame
     void Update () {
         if(transform.position.y <= 1.0f)
         {
             renderer.enabled = true;
         }
     }
 }

Add this script to any object with a rigidbody set it's height to anything more than 1, say 10. Also disable the mesh renderer from inspector itself.

Then play the scene, now if the game object is not only loaded in the memory then it will never show up since it will not fall below y position of 1 since it is not present in the memory itself.

But on the contrary the object is visible after it reaches height of 1 because since it has a rigidbody it was falling down due to gravity which means the object was loaded in the memory and was being processed upon.

Also even when the object is deactivated it is still kept in the memory so that it does not need to be loaded when it is activated since loading resources from disc is a heavy job.

Comment
Add comment · 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

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

28 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

Related Questions

A node in a childnode? 1 Answer

Multiple instances of static mesh increase size of game build 1 Answer

Streaming Support 2 Answers

Making a game object un-render or turn-invisible through trigger? 1 Answer

How many objects is too many? 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