好像我在这里遗漏了一些东西,使用最新版本的Unity,我在点击时实例化一个游戏对象..它在场景视图中显得很好但在游戏视图中却没有?
我用Google搜索并尝试了所有这些回复.
我检查了屏幕右上角的图层,它们都显示了,而且z值低于相机'但老实说,我已经尝试过几乎所有的z位置.
我正在产生的游戏对象是一个带有僵硬身体的精灵,但那不应该对吗?它出现在场景视图中,游戏视图应该只显示场景的作用?
有什么想法吗?
我已经google了很多,只提出了非常复杂的方法.我还发现函数OnMouseDown()但我无法使其工作.
当你点击屏幕上的任何地方时,精灵激活.
编辑 - 是的它有一个2d Box对撞机
我的代码如下:
using UnityEngine;
using System.Collections;
public class mute : MonoBehaviour {
public bool isMuted = false;
public Sprite mute1; // Drag your first sprite here
public Sprite mute2; // Drag your second sprite here
private SpriteRenderer spriteRenderer;
// Use this for initialization
void Start () {
spriteRenderer = GetComponent<SpriteRenderer>(); // we are accessing the SpriteRenderer that is attached to the Gameobject
if (spriteRenderer.sprite == null) // if the sprite on spriteRenderer is …Run Code Online (Sandbox Code Playgroud)