コード例 #1
0
    public void SetPlayer(PlayerMove _player)
    {
        player = _player;
        gameObject.transform.SetParent(player.gameObject.transform);

        if ((playerHealth = _player.GetComponent <Health>()) != null)
        {
            playerHealth.healthChanged += UpdateHealthBar;
        }
        else
        {
            healthFill.enabled       = false;
            healthBackground.enabled = false;
        }

        playerWeaponManager = _player.GetComponent <WeaponManagerOff>();
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        rb            = GetComponent <Rigidbody>();
        weaponManager = GetComponent <WeaponManagerOff>();

        health = GetComponent <Health>();

        //ui stuff
        playerUIInstance      = Instantiate(playerUIPrefab);
        playerUIInstance.name = playerUIPrefab.name;

        UI ui = playerUIInstance.GetComponent <UI>();

        if (ui != null)
        {
            ui.SetPlayer(GetComponent <PlayerMove>());
        }
        else
        {
            Debug.Log("No ui component found");
        }
    }