csharp 使用游戏对象上下文在GameObject上创建子容器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 使用游戏对象上下文在GameObject上创建子容器相关的知识,希望对你有一定的参考价值。

using UnityEngine;

public class ShipHealthHandler : MonoBehaviour
{
    private float health = 100;

    private void OnGUI()
    {
        GUI.Label(new Rect(Screen.width / 2, Screen.height / 2, 200, 100), "Health: " + this.health);
    }

    public void Take_damage(float damage)
    {
        this.health -= damage;
    }
}

以上是关于csharp 使用游戏对象上下文在GameObject上创建子容器的主要内容,如果未能解决你的问题,请参考以下文章