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 /
  • Help Room /
This question was closed Jan 23, 2018 at 03:55 PM by Jurak1908 for the following reason:

Problem found in import settings... i'm not the sharpest tool in the shed

avatar image
0
Question by Jurak1908 · Jan 18, 2018 at 07:45 PM · mobilespeedperformance optimizationinstantiate prefabobject pool

Performance-increase/loading-time problem [object pool]

Hello guys! :)


I'm currently working on a project, a simple game which should be playable on mobile. Since I'm a bloody beginner, my first idea was simply instantiating objects - which caused micro lags to appear. I researched, read about object-pooling and tried to create a simple one based on just the idea... without tutorials and stuff. So it's clearly not perfect.


The pool creates various tiles, which will spawn randomly depending on some factors. The problem is, that instantiating all the objects just takes way to long. The editor preview needs about 30 seconds while the mobile version will even load 1 minute.


My question is: Will it make my game/level-loading faster if i place the objects in the scene by hand and configure the pool to use those? If so, could i just let the pool create the objects and kind of "save" the state and past it in the scene? If not, are there any other ways to optimize my pool for faster loading? How should i deal with this problem?


The basic pool-creation-script:


     public GameObject[] tilePrefabs;
     GameObject[] tilePool;
     bool[] tileIsUsed;
     public int tilesOfEach; //how many tiles of each type
     Vector2[] poolPosition;
     Vector2[] spawnPositions;
 
     void createTilePool() {
         tilePool = new GameObject[tilePrefabs.Length * tilesOfEach];
         poolPosition = new Vector2[tilePrefabs.Length * tilesOfEach];
         tileIsUsed = new bool[tilePrefabs.Length * tilesOfEach];
         Vector2 poolSpawn = new Vector2 (35, 45);
         int tilePoolIndex = 0;
         for (int i = 0; i < tilePrefabs.Length; i++) {
             for (int z = 0; z < tilesOfEach; z++) {
                 tilePool[tilePoolIndex] = Instantiate (tilePrefabs [i], poolSpawn, Quaternion.identity);
                 tilePool [tilePoolIndex].GetComponent<TileMovement> ().disableMovement ();
                 tilePool [tilePoolIndex].GetComponent<TileMovement> ().poolIndex = tilePoolIndex;
                 poolPosition [tilePoolIndex] = poolSpawn;
                 tileIsUsed [tilePoolIndex] = false;
                 tilePoolIndex++;
                 poolSpawn.x = poolSpawn.x + 10;
             }
             poolSpawn.x = 35;
             poolSpawn.y = poolSpawn.y - 20;
         }            
     }
 



Thanks in advance! :)

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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

155 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 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 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 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 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 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

Dual Touch Controls Problem 1 Answer

Instantiate Objects in Pattern using UI Slider 1 Answer

NullReferenceException: Object reference not set to an instance of an object 0 Answers

Mobile Performance Issues 0 Answers

No physics object gravity-driven movement? 0 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