Greetings,
We are trying to deploy a game on Windows Phone, but our team occured a bug on which we cannot find a solution. After building and installing the game, the game starts just fine, but some of the scripts are getting
A script behaviour has a different serialization layout when loading. (Read 24 bytes but expected 32 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
The most important script in which it occurs:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ListAdapter : MonoBehaviour {
[System.Serializable]
public enum Fills{ level,levelGroups,upgrades,balls,shops,other,friends};
private float height;
public somethingInfo[] infos;
public Fills fillsType = Fills.level;
public bool clearOnShow = false;
[System.NonSerialized]
private GameObject content;
public void OnEnable()
{
content = transform.FindChild("ScrollRect/Content").gameObject;
rePaint ();
}
float ratio = 4.11f;
public double rectHeight;
public void Start()
{
// rePaint();
}
public float getHeight()
{
return height;
}
ArrayList infosList = new ArrayList ();
public void rePaint()
{
if (infos == null) {
switch (fillsType) {
case Fills.level:
infos = BallGame.getInstance ().levels.ToArray();
ratio = 4.11f;
break;
case Fills.upgrades:
infos = BallGame.getInstance ().upgrades;
ratio = 4.11f;
break;
case Fills.balls:
infos = BallGame.getInstance ().balls;
ratio = 4.11f;
break;
case Fills.shops:
infos = BallGame.getInstance ().shops;
ratio = 4.11f;
break;
case Fills.levelGroups:
infos = BallGame.getInstance().levelGroups;
ratio = 4.11f;
break;
case Fills.friends:
ratio = 7.56f;
// infos = BallGame.getInstance().levelGroups;
return;
break;
default:
break;
}
}
//content.GetComponent<RectTransform>().offsetMin = new Vector2(0, content.GetComponent<RectTransform>().offsetMin.y);
//content.GetComponent<RectTransform>().offsetMax = new Vector2(0, content.GetComponent<RectTransform>().offsetMax.y);
/// POCZATEK COPYPSTY
///
Debug.Log("list start" + gameObject.name);
GameObject scrollView = content.gameObject;
RectTransform ScrollViewRT = scrollView.GetComponent<RectTransform>();
// rectHeight = (scrollView.GetComponent<RectTransform>().rect.width-200) /4.11 * infos.Length;
rectHeight = (scrollView.GetComponent<RectTransform>().rect.width) / ratio * infos.Length;
//double a=(rectHeight/Screen.height-1)*0.6;
double a = (rectHeight / (scrollView.GetComponent<RectTransform>().rect.height/ scrollView.GetComponent<RectTransform>().anchorMax.y));
Debug.Log("dupa " + scrollView.GetComponent<RectTransform>().rect.width + " " + scrollView.GetComponent<RectTransform>().rect.height + " " + rectHeight + " " + a);
scrollView.GetComponent<RectTransform>().anchorMax = new Vector2(1f, (float)a);
Debug.Log("RECT_WIDTH = " + GetComponentInChildren<RectTransform>().rect.width);
Debug.Log("INFOS_LENGTH = " + infos.Length);
Debug.Log("RECT_HEIGHT = " + scrollView.GetComponent<RectTransform>().rect.height);
height = scrollView.GetComponent<RectTransform>().rect.height;
//scrollView.GetComponent<RectTransform>().anchorMin = new Vector2(1f, scrollView.GetComponent<RectTransform>().rect.height);
//ScrollViewRT.rect.height = rectHeight;
///KONIEC KOPYPASTY
if (clearOnShow && infos.Length > 0)
foreach(GameObject o in infosList)
{
Destroy(o);
Debug.Log("Kochanie usunąłem dzieciaki");
}
for (int i=0;i<infos.Length;i++)
{
Debug.LogError("rePaint 5 "+i);
if (!infos[i].hidden)
{
//GameObject scrollView = content.gameObject; // przez copypaste nastepny wiersz zamieniony za ten
scrollView = content.gameObject;
Debug.Log ("enableing"+i);
if(infos[i].hasView()&&!clearOnShow)
infos[i].getView();
else
{
if (clearOnShow)
infos[i].setView(null);
GameObject levelInfo=infos[i].getView();
levelInfo.transform.position=scrollView.transform.position;
levelInfo.transform.rotation=scrollView.transform.rotation;
//levelInfo.transform.rotation=Quaternion.identity;
levelInfo.transform.SetParent( scrollView.transform);
levelInfo.GetComponent<RectTransform>().localScale=new Vector3(1f,1,1);
// Vector3 pos=levelInfo.GetComponent<RectTransform>().anchoredPosition3D;
// pos.y=200-i*100;
// levelInfo.GetComponent<RectTransform>().anchoredPosition3D=pos;
// levelInfo.GetComponent<RectTransform>().rotation=Quaternion.Euler(Vector3.zero);
infosList.Add (levelInfo);
}
}
}
//content.GetComponent<RectTransform>().localPosition = new Vector3 (0,0,0);
// content.GetComponent<RectOffset>().right = 0;
//content.GetComponent<RectTransform>().rect.set(top, left, width, height);
/// USTAWIENIE CONTENTU NA SRODEK// DALEJ NIE DZIALA - widocznie jest przesuwany gdzies dalej
///
Debug.LogError("rePaint end");
}
}
We debugged it for a while and the problem is which “Gameobject content” if we comment this very line, the serialization problems ends, but the scripts does not work without it of course. We tried to make it private, non-serializable, serializable and many many more.
We googled the problem, tried numerous solutions which didn’t work in our case and now we seek for help here.
Any advices will be appreciated!