Home unity3d Procedural Generation of the House or something in Unity

Procedural Generation of the House or something in Unity




I created a household generator and a custom editor for the inspector, but there were questions:

  1. I am building a house from the blocks that I overeat in the inspector, and make them copies through Instantiate, as a result I have a cousa of instances of this object in the hierarchy window. Is it normal, on performance affects?

  2. I need to dynamically change the house under the parameters entered into the instructor, how can I count that some field changed?

  3. At the same time, a visselo, you need to destroy all the descendants, I found a function that goes through them all and causes Destroy (). But she somehow does not always work correctly. It makes sense to not delete objects, and save links to them and remove unused elements to some pool?

Answer 1

  1. exactly the same amount affects performance as the created objects without initialization by software code, but by creating through the Editor. There is still much more on what components you hang on every object. If you have a lot of elements with Rigitbody – I mean what will be labeled) Duggle performance tests with different number of boxes or barrels in unity.
  2. When changing any variable in the inspector, OnValidate is called. It’s you and you can use for yourself.
  3. Make a method that kills all the children of the object, and then causes me a destroy at yourself.
Public void DestroyMeandchildren ()
     Foreach (Transform Child in GameObject.transform) {
       GameObject.destroy (child.gameObject);

Answer 2, Authority 100%

  1. and kusa is how much? And how many polygons, materials, permission?
  2. in Custom Editor This is done very simply by assigning a value from a guilayout, another variable and comparing this variable and the Target class field.
  3. Destroy whose descendants? The editor needs to use DESTROYIMMEDIATE .

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions