VR learning Amusement Park (2) - to select the scene play equipment

(A) Basic Settings

Into the "Milky Way" shader repository, set the zoom parameter, the camera wrapped them;

Canvas set resolution is 1920 * 1080, RenderMode preferably from world space; adjust the position, as shown in view.

 

 (B) setting a required scene select setting patch, position (0,0, -2000), a null object set (0,0,0), the surface of the sheet as a sub-object of the object space. The preform as GameItem generated automatically, using the code.

In the game is running, generated under GameItemSpan GameItem, define a Material's [], the rotation angle of each selection private float m_Angle;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class GameItemSelect : MonoBehaviour
{
    public static GameItemSelect _Instance;
    public Material[] m_gameItemMatArr;
    public GameObject go_GameItem;
    private float m_Angle;
    public int Index = 0;


    private void Awake()
    {
        _Instance = this;
        m_Angle = 360.0f / m_gameItemMatArr.Length;
        for (int i = 0; i < m_gameItemMatArr.Length; i++)
        {
            GameObject go = Instantiate(go_GameItem, transform);
            go.transform.localEulerAngles = new Vector3(0, i * m_Angle, 0);
            go.GetComponentInChildren<MeshRenderer>().material = m_gameItemMatArr[i];
            go.GetComponentInChildren<GameItem>().SetVideoName(m_gameItemMatArr[i].name);
            go.GetComponentInChildren<GameItem>().Index = i;
        }

    }

    public void RotateForWord()
    {
        Index++;
        if (Index >= m_gameItemMatArr.Length)
        {
            Index = 0;
        }
        transform.DORotate(new Vector3(0, -Index * m_Angle, 0), 0.3f);
    }
    public void RotateBack()
    {
        Index--;
        if (Index < 0)
        {
            Index = m_gameItemMatArr.Length - 1;
        }
        transform.DORotate(new Vector3(0, -Index * m_Angle, 0), 0.3f);
    }
}

 

Guess you like

Origin www.cnblogs.com/dream-seeker-201907/p/11433119.html