【サバイバルホラーゲームを作りたい。その7】

今回もこちらの動画をやっていきます。
youtu.be

今回は画面のFADINGと十字線を実装します。

・十字線を作ります。

・フェードインする画面を設置します。

・下記のスクリプトを追加します。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using StarterAssets;
using UnityEngine.UI;

public class AOpening : MonoBehaviour //EP7追加 Sequences直下の同じ名前のオブジェクトにアタッチ
{
    public GameObject ThePlayer;
    public GameObject FadeScreenIn;
    public GameObject TextBox;

    // Start is called before the first frame update
    void Start()
    {
        ThePlayer.GetComponent<FirstPersonController>().enabled = false;
        StartCoroutine(ScreenPlayer());
    }

    IEnumerator ScreenPlayer()
    {
        yield return new WaitForSeconds(1.5f);
        FadeScreenIn.SetActive(false);
        TextBox.GetComponent<Text>().text = "I need to get out here.";
        yield return new WaitForSeconds(2);
        TextBox.GetComponent<Text>().text = "";
        ThePlayer.GetComponent<FirstPersonController>().enabled = true;

    }  
}

今回は以上です。