- Home /
Phone App(not game) : should I load UI panels as assets or load it as new scene?
Hello everyone,
we're developing a phone app and as far as I know, the concept of activity(from android) is not well described on Unity.
Top down approach of what I want to do:
I want to implement activities(again, similar to those from android studio), using the UI of unity and c# code to handle UI events. An activity is one gameobject(panel with handling scripts) with children gameobjects(buttons, texts...).
I want to compromise between loading time and memory allocation. I was able to think about 3 approaches as solution:
1st Approach:
Group related panels together and make every group one scene. in every scene, show the panel we want to use using the "enabled" variable. because all scripts are just ui events handling, there will be nothing in the update() function and the panels scripts will not "overlap".
pros:
1.No loading time when we switch between panels(in same scene).
2.Panels' animations are easy to implement.
3.we can access any other script's functions and variables from any script we want.
4.Data will not be lost unless we clear them manually.
5.Easy to implement back function (back from details panel to items list panel) .
cons:
1.High usage of memory?
2.We have to clear unused data manually.
3.There will be one large group, and the rest will be minor groups.
2nd Approach:
We put every panel in different scene and we load it only when needed. Accordingly, we use DontDestroyOnLoad for the panels we don't want to lose.
pros:
1.Optimized memory usage.
2.Activities are more organized(every panel in different scene).
cons:
1.We have to avoid duplication in panels and I believe this is going to be messy.
2.If user go from scene1 to scene2 without destroying the panel from scene1, then he decided to go from scene2 to scene3, it's hard then to know if the panel from scene1 is still there and that we shouldn't destroy it.
3rd Approach:
we create one scene and load needed panels as prefab at runtime. We can do it using the line below:
Instantiate (Resources.Load ("panel1_prefab") as GameObject);
pros:
1.Easy way to avoid panels duplication.
2.Optimized memory usage.
3.Frequently used panels will never be destroyed(solve 3rd cons of 2nd approach).
4.Unused panels will never be loaded.
cons:
1.Is Resources.Load faster than loadscene?
I would like to use the first approach since panel size is negligible comparing to content size, but we still don't have overall view on panels count and size...and what panels are related to each other(grouping).
Any thoughts/ideas from experts in this case?
Thanks for reading
Your answer
Follow this Question
Related Questions
How to have 2 sets of textures and make sure only one is loaded? 0 Answers
Memory usage for the simplest iOS/Android app grows over time, says Unity 3.5 Profiler 0 Answers
Detect how much RAM is available? (iOS) 1 Answer
OutOfMemoryException when downloading files via the www class (iOS and Android) 1 Answer
iOS memory inconsistent between builds 0 Answers