[英]Unity - Sprites Go Away In Scene View, But Not Game View
Coding Language: C#编码语言:C#
Experience: I know my way around the basics经验:我了解基础知识
I am currently trying to make a 2D unity game, and the goal is to break blocks.我目前正在尝试制作 2D 统一游戏,目标是打破块。 To achieve this, the sprite uses a "hit point" system, then deletes it's self when it hits zero.
为了实现这一点,精灵使用了一个“生命值”系统,然后在它达到零时删除它的自身。 BUT , for some odd reason, Unity keeps the sprite loaded in the game view.
但是,出于某种奇怪的原因,Unity 将精灵加载到游戏视图中。 It is gone in my scene view, so I know it is working.
它在我的场景视图中消失了,所以我知道它正在工作。 It just won't disappear in my game view.
它不会在我的游戏视图中消失。 I have tried searching for some sort of refresh for the SpriteRenderer component, but I can't seem to find anything.
我尝试为 SpriteRenderer 组件搜索某种刷新,但我似乎找不到任何东西。
private void Start()
{
if (depthMultiplier == 0)
{
hitPoints = 3;
}
}
void OnMouseDown()
{
hitPoints -= 1;
Debug.Log(hitPoints);
if (hitPoints == 0)
{
GameObject.Find("PlayingScreen").GetComponent<Spendables>().gold += 1;
Destroy(gameObject);
}
}
} }
Code I am currently using我目前使用的代码
Sprites go away in scene view, but not game view.精灵 go 在场景视图中离开,但不是游戏视图。
EDIT - Might be worth nothing, I am using an Orthographic camera, and the object is also removed from the hierarchy编辑 - 可能一文不值,我使用的是正交相机,并且 object 也从层次结构中删除
Ok, fixed my own problem.好的,解决了我自己的问题。 After messing around with the camera for a little while, I found the Clear Flags property.
在把相机弄乱了一会儿之后,我找到了Clear Flags属性。 Apparently, I had just turned this off instead of changing the Skybox.
显然,我只是将其关闭而不是更改 Skybox。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.