0
点赞
收藏
分享

微信扫一扫

9. 基于Unity的VR艺术画廊

9. 基于Unity的VR艺术画廊

using UnityEngine;

public class VRArtGallery : MonoBehaviour
{
    public GameObject[] artPieces;
    private int currentArtIndex = 0;

    void Start()
    {
        if (artPieces.Length > 0)
        {
            LoadArtPiece(0);
        }
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            PreviousArtPiece();
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            NextArtPiece();
        }
    }

    void LoadArtPiece(int index)
    {
        for (int i = 0; i < artPieces.Length; i++)
        {
            artPieces[i].SetActive(i == index);
        }
    }

    void PreviousArtPiece()
    {
        currentArtIndex = (currentArtIndex - 1 + artPieces.Length) % artPieces.Length;
        LoadArtPiece(currentArtIndex);
    }

    void NextArtPiece()
    {
        currentArtIndex = (currentArtIndex + 1) % artPieces.Length;
        LoadArtPiece(currentArtIndex);
    }
}    void LoadArtPiece(int index)
    {
        for (int i = 0; i < artPieces.Length; i++)
        {
            artPieces[i].SetActive(i == index);
        }
    }

    void PreviousArtPiece()
    {
        currentArtIndex = (currentArtIndex - 1 + artPieces.Length) % artPieces.Length;
        LoadArtPiece(currentArtIndex);
    }

    void NextArtPiece()
    {
        currentArtIndex = (currentArtIndex + 1) % artPieces.Length;
        LoadArtPiece(currentArtIndex);
    }
}    void LoadArtPiece(int index)
    {
        for (int i = 0; i < artPieces.Length; i++)
        {
            artPieces[i].SetActive(i == index);
        }
    }

    void PreviousArtPiece()
    {
        currentArtIndex = (currentArtIndex - 1 + artPieces.Length) % artPieces.Length;
        LoadArtPiece(currentArtIndex);
    }

    void NextArtPiece()
    {
        currentArtIndex = (currentArtIndex + 1) % artPieces.Length;
        LoadArtPiece(currentArtIndex);
    }
}

举报

相关推荐

9. 进程

9. python的if语句

9.索引的使用

9. 优化器

9. 回文数

9.因子数

0 条评论