【问题标题】:Unity Canvas Doesn't Show on DeviceUnity Canvas 不显示在设备上
【发布时间】:2015-05-09 06:52:20
【问题描述】:

正在开发一个 Unity 应用程序,并尝试制作一个基本的菜单屏幕。

我运行 Unity 5.0.1p3。

虽然无关紧要,但这可能很重要:我的应用使用 Vuforia,其他场景没有问题。

因此,当我尝试使用默认 Unity 相机创建菜单屏幕并添加画布时,它在 Unity 编辑器上完美运行,但在设备上却无法正常运行。

在设备上,我只获得了背景(即相机前面的平面),而图像/按钮不显示画布上的任何内容。

此外,当应用程序在 Eclipse LogCat 上启动时,我收到此错误:

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?

只有在我导出菜单脚本后才会出现此问题。 在您开始将我链接到有关序列化问题的先前问题之前,我已经检查了他们的问题,但我不知道这与我的问题有何关系。

MenuScreen.cs如下:

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");
        }

    }

}

【问题讨论】:

  • “导出”脚本到底是什么意思?
  • 比如,将包含脚本的场景添加到 Build 中。对此感到抱歉。

标签: c# android eclipse unity3d unity3d-gui


【解决方案1】:

你需要改变ARCamera的backgroundPlane的shader 只需选择你的 ARCamera,在它下面你会找到相机和它的 BackgroundPlane。选择它并将着色器更改为 Mobile/Diffuse。希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-14
    • 1970-01-01
    • 2016-11-14
    • 2016-11-06
    相关资源
    最近更新 更多