unity做可视化音乐播放器_生成图形篇(圆形)

来源:互联网 发布:开票软件默认密码 编辑:程序博客网 时间:2024/05/29 16:51
using UnityEngine;
using System.Collections;




public class cycle : MonoBehaviour
{
    public GameObject circleModel;
    public GameObject lookcenter;
    //旋转改变的角度
    public int changeAngle = 0;
    //旋转一周需要的预制物体个数
    private int count;


    private float angle = 0;
    public float r = 5;


    // Use this for initialization
    void Start()
    {
        count = (int)360/ changeAngle;
        for (int i = 0; i < count; i++)
        {
            Vector3 center = lookcenter.transform.position;
            GameObject cube = (GameObject)Instantiate(circleModel);
            float hudu = (angle / 180) * Mathf.PI;
            float xx = center.x + r * Mathf.Cos(hudu);
            float yy = center.y + r * Mathf.Sin(hudu);
            cube.transform.position = new Vector3(xx, yy, 0);
            cube.transform.LookAt(center);
            angle += changeAngle;
        }
    }

}


用最初的Cube生成一个自定义图形,从而组成音谱效果