# unity 摄像机

  1. skybox
    添加材质改变天空中的样式
  2. rendering-proirity
    改变深度可以改变默认相机的顺序,深度较大的可以改为仅深度,此时两个画面会互补叠加

# 播放声音

  1. 组件:audio source
    row
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    void Start()
    {
    player = GetComponent<AudioSource>();
    // 设置播放的音频片段
    player.clip = music;
    // 循环
    player.loop = true;
    // 音量
    player.volume = 0.5f;
    // 播放
    player.Play();
    }

    void Update()
    {
    // 按空格切换声音的播放和暂停
    if (Input.GetKeyDown(KeyCode.Space))
    {
    // 如果当前正在播放声音
    if (player.isPlaying)
    {
    // 停止播放
    player.Pause();
    // player.Stop();
    }
    else
    {
    // 播放
    player.UnPause();
    }
    }

    //按鼠标左键播放
    if (input.GetMouseButtonDown(0)){
    player.PlayOneShot(se);
    }
    }

# 视频播放

  1. 组件: video player
    row
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    using UnityEngine.Video;

    public class VideoTest : MonoBehaviour
    {
    private VideoPlayer player;

    // Start is called before the first frame update
    void Start()
    {
    player = GetComponent<VideoPlayer>();
    }

    // Update is called once per frame
    void Update()
    {
    if (Input.GetMouseButtonDown(0))
    {
    // 鼠标左键点击时执行的操作
    }
    }
    }

# 玩家 移动

  1. 组件: Character Controller
  2. 自定义组件设置
    ROW
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    private CharacterController player;
    // Start is called before the first frame update
    void Start()
    {
    player = GetComponent<CharacterController>();
    }

    // Update is called once per frame
    void Update()
    {
    //水平
    float horizontal = Input.GetAxis("Horizontal");
    //垂直
    float vertical = Input.GetAxis("Vertical");
    //创建成方向向量
    Vector3 dir = new Vector3 (horizontal, 0, vertical);
    //移动
    player.SimpleMove(dir);
    }

# 重力

  1. 组件: rigidbody

# 碰撞器