简体   繁体   中英

Unity - Sprites Go Away In Scene View, But Not Game View

Coding Language: 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. 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. 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.

     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.

EDIT - Might be worth nothing, I am using an Orthographic camera, and the object is also removed from the hierarchy

Ok, fixed my own problem. After messing around with the camera for a little while, I found the Clear Flags property. Apparently, I had just turned this off instead of changing the Skybox.

Clear Flags Property

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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