Copyright Notice:
- Original article published on the blog Park "You dream maker culture," the blog space (URL:
http://www.cnblogs.com/raymondking123/
) and micro-channel public number "dream maker culture" - You are free to reprint, but must include the full copyright notice!
aims
First, let's preview the effect after completion:
- Create a platform
- Create a circle
- The rotating ring
Create a platform
First, open the Windows directory to find our Unity in the menu bar, click to open the find Package Manager (note, Unity version must be later 2017 version) option and click Open, then we'll pop up a window, as shown below:
- And then wait for the bottom right corner of the load is complete, find ProBuilder plug-in, click Open and then click Installing installation.
Wait for the installation to complete When you find the menu bar Tools directory, open the directory selection ProBuilder under the ProBuilder Window Options
And open, open a pop-up window ProBuilder
Click New Shape, and Shape Selector to the Cylinder, and adjusted to the value shown below
Click the Build button, and then create the change out of the platform is made of their favorite color to
Creating and of the rings
Create an empty GameObject rename Yrig and its position is set to the center of the disk,
a new script Platform rename and add to the platform, the scripting code is then opened as shown below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.ProBuilder;
public class Platform : MonoBehaviour
{
public Material mat;//圆环的材质
public Transform Yrig;//
// Start is called before the first frame update
public void Star()
{
//创建圆环
ProBuilderMesh pbMesh = ShapeGenerator.GenerateArch(PivotLocation.FirstVertex, deg, radius, 0.5f, 1, 20, true, true, true, true, true);
pbMesh.GetComponent<MeshRenderer>().material = mat;
//使圆环平躺
pbMesh.transform.Rotate(-90, 0, 0);
Yrig = new GameObject("yRig").transform;
pbMesh.transform.SetParent(Yrig,false);
}
// Update is called once per frame
void Update()
{
transform.Rotate(0, 1, 0);
}
}
Remember mat to give its assignment within the script (create a new good Material choose their favorite color to go in drag) as shown:
Finally, click the Run button Unity will be able to see the ring can be rotated.