Hello,
I just finished, built and uploaded my game to the Google Play Store and I just noticed that the build size is quite big considering it's actual functionality. All the game does is show you some text and some icons and then change the text and icons when you tap. The text and the icons come from a list.
I read that you can reduce the size of your build by avoiding System.dll, but in order to use the list I need System.generics. So I am looking for an alternative to the list so that I can reduce the size of mye build.
Also any other tips on how to reduce the size of the game is very welcome.
Here is my editor log, showing what makes up the size of the build, as well as the dlls I'm using.
Textures 235.2 kb 4.7%
Meshes 0.0 kb 0.0%
Animations 0.0 kb 0.0%
Sounds 0.0 kb 0.0%
Shaders 175.5 kb 3.5%
Other Assets 45.9 kb 0.9%
Levels 7.3 kb 0.1%
Scripts 482.5 kb 9.7%
Included DLLs 3.9 mb 80.8%
File headers 8.5 kb 0.2%
Complete size 4.9 mb 100.0%
Mono dependencies included in the build
Dependency assembly - Mono.Security.dll
Dependency assembly - System.Core.dll
Dependency assembly - System.dll
Dependency assembly - mscorlib.dll
Dependency assembly - UnityEngine.Advertisements.dll
Dependency assembly - UnityEngine.UI.dll
Dependency assembly - UnityEngine.Networking.dll
Dependency assembly - Assembly-CSharp.dll
As you can see, dlls take up more than 75% of the size, which is inconvenient.
Here's how I use the List
using UnityEngine;
using System.Collections.Generic;
public class ListOfStatements : MonoBehaviour {
List statements;
public List shuffledList;
// Use this for initialization
void Awake () {
statements = new List();
shuffledList = new List();
FillList();
for (int i = 0; i < statements.Count;)
{
int r = Random.Range(0, statements.Count);
shuffledList.Add(statements[r]);
statements.Remove(statements[r]);
}
foreach (Statement s in shuffledList)
{
Debug.Log(s.text + " " + s.drinks + " " + s.category);
}
}
// Update is called once per frame
void FillList ()
{
statements.Add(new Statement("Vært vikar", 1, 1));
statements.Add(new Statement("Vært barnevakt", 2, 1));
statements.Add(new Statement("Bygd trehytte", 1, 1));
statements.Add(new Statement("Gravd en snøhule", 1, 1));
These are just 4 of the 300 or so statements in my List.
This is a Statement
public class Statement
{
public string text;
public int drinks;
public int category;
public Statement(string _text, int _drinks, int _category)
{
text = _text;
drinks = _drinks;
category = _category;
}
}
Aaand here's how I change the statements
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Advertisements;
public class StatementManager : MonoBehaviour {
public Text currentStatement;
public GameObject oneDrink, threeDrink, fiveDrink, oneShot;
GameObject currentDrink;
ListOfStatements listOfStatements;
int listIndex = 0;
public bool ranOnce = false;
int adIndex = 15;
void Awake()
{
listOfStatements = GetComponent();
}
void Start()
{
currentStatement.text = listOfStatements.shuffledList[0].text;
ChangeIcon();
}
public void ChangeText()
{
if (!ranOnce)
{
if (listIndex == adIndex)
{
adIndex += 15;
//ShowDefaultAd();
}
ranOnce = true;
listIndex++;
Destroy(currentDrink);
currentStatement.text = listOfStatements.shuffledList[listIndex].text;
ChangeIcon();
}
if (listIndex == listOfStatements.shuffledList.Count-1)
{
listIndex = 0;
}
}
void ChangeIcon()
{
switch (listOfStatements.shuffledList[listIndex].drinks)
{
case 1:
currentDrink = Instantiate(oneDrink);
break;
case 2:
currentDrink = Instantiate(threeDrink);
break;
case 3:
currentDrink = Instantiate(fiveDrink);
break;
case 4:
currentDrink = Instantiate(oneShot);
break;
}
}
using UnityEngine;
public class TouchManager : MonoBehaviour
{
StatementManager statementManager;
void Awake()
{
statementManager = GetComponent();
}
void Update()
{
if (Input.touchCount > 0)
{
statementManager.ChangeText();
}
if (Input.touchCount < 1)
{
statementManager.ranOnce = false;
}
}
}
Basicly, every Statement has a String and an int that decides what Text to show and which icon to show with it. The Statement has an int Category as well, which is not used in this build, but is in there for integrating a new function later.
I need a list or an array to hold these Statements and let me sequentially cycle through them.
Also, if you have any ideas on optimizing the shuffling of the List, I'd gladly accept.
↧