简体   繁体   English

统一3D遥控器和C#错误?

[英]unity 3d remote and c# error?

I want to simulate unity 3d remote and c# script to test touch response. 我想模拟统一的3d遥控器和c#脚本来测试触摸响应。

In my android device and I am getting error on playing the referenced script on this is behaviour is missing . 在我的android设备上,在播放the referenced script on this is behaviour is missing时出现错误the referenced script on this is behaviour is missing

Please solve this problem. 请解决这个问题。

using UnityEngine;
using System.Collections;

public class TouchSripts : MonoBehaviour {

    // Use this for initialization
    void OnGui()
    {
        foreach (Touch touch in Input.touches)
        {
            string message = "";
            message += "ID: " + touch.fingerId + "\n";

            message += "phase :" + touch.phase.ToString() + "\n";
            message += "TapCount:" + touch.tapCount + "\n";
            message += "Pos x :" + touch.position.x + "\n";
            message += "Pos y:" + touch.position.y+ "\n";

            int num = touch.fingerId;
            GUI.Label(new Rect(0 + 130 * num, 0, 120, 100) ,message);
        }
    }

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

}

This error is called when Unity can not access a script, usually because names are not matching up. 当Unity无法访问脚本时(通常是因为名称不匹配),将调用此错误。 So simply make sure your script inside the project window is the same as your class name (TouchSripts). 因此,只需确保您在项目窗口中的脚本与您的类名(TouchSripts)相同即可。 Sometimes that doesn't correctly fix it so just Select All and Copy the script, go back into unity, delete the old script, create a new script (making sure to call it TouchSripts), and delete the content of the new script, and paste your script into it. 有时,这并不能正确解决问题,因此只需全选并复制脚本,恢复统一,删除旧脚本,创建新脚本(确保将其命名为TouchSripts),然后删除新脚本的内容,然后将您的脚本粘贴到其中。

Hope it helps! 希望能帮助到你!

You probably mistyped a reference somewhere in your scripts. 您可能在脚本中的某处输入了错误的引用。 It's also possible you forgot to assign something in the inspector. 您也有可能忘记在检查器中分配某些内容。 This is not an unity remote issue, you should get the same error when testing in the Editor 这不是一个统一的远程问题,在编辑器中进行测试时应该出现相同的错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM