samedi 9 mai 2015

Unity Canvas Doesn't Show on Device

Working on a Unity App, and trying to make a basic Menu Screen.

I run Unity 5.0.1p3.

Although irrelevant, this might be important: My app uses Vuforia, and thge other scenes have no problem.

So, when I try to create a Menu Screen using the default Unity Camera, and add a canvas, it works perfectly on the Unity Editor but not on the device.

On the device, I just get the background (which is plane in front of the camera) and the Image/Button doesn't show anything that's on the canvas.

Also, while the app starts on Eclipse LogCat I get this error:

05-09 11:18:14.047: E/Unity(2092): A script behaviour has a different serialization layout when loading. (Read 32 bytes but expected 52 bytes)
05-09 11:18:14.047: E/Unity(2092): Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
05-09 11:18:14.047: E/Unity(2092):  
05-09 11:18:14.047: E/Unity(2092): (Filename: ./Runtime/Serialize/SerializedFile.cpp Line: 1652)
05-09 11:18:14.047: E/Unity(2092): A script behaviour has a different serialization layout when loading. (Read 32 bytes but expected 124 bytes)
05-09 11:18:14.047: E/Unity(2092): Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

And this problem shows only after I export my Menu script. Before you start linking me to previous questions regarding the serialization problem, I've already checked out their problem and I don't know how this relates to mine.

MenuScreen.cs is as follows:

using UnityEngine;
using System.Collections;

public class MenuScreen : MonoBehaviour {

    private Rect b;
    private Rect o;
    private Rect f;


    // Use this for initialization
    void Start () {

        int w = Screen.width;
        int h = Screen.height;

        //name = new Rect ( px ,py ,bh, bw)
        b = new Rect (w -3*w/4, h - 4*h/5 , 2*w/4, h / 10);
        o = new Rect (w -3*w/4, h - 3*h/5 , 2*w/4, h / 10);
        f = new Rect (w -3*w/4, h - 2*h/5 , 2*w/4, h / 10);

    }

    // Update is called once per frame
    void OnGUI(){

        if (GUI.Button (b, "Begin")) {
            Application.LoadLevel("SolidWhite");
        }


        if (GUI.Button (o, "Options")) {
            //Application.LoadLevel("Options");
        }

        if (GUI.Button (f, "FAQ")) {
            //Application.LoadLevel("FAQ");
        }

    }

}

Aucun commentaire:

Enregistrer un commentaire