コード例 #1
0
        void ResetSegments()
        {
            if (segments != null && segments.Count > 0)
            {
                for (int i = 0; i < segments.Count; i += 0)
                {
                    GameObject tempSegment = segments[0];
                    segments.RemoveAt(0);
                    Destroy(tempSegment);
                }
            }
            if (shaderOverride == null)
            {
                segmentMaterial = new Material(Shader.Find("Unlit/Color"));
            }
            else
            {
                segmentMaterial = new Material(shaderOverride);
            }

            segmentMaterial.color = ValidColor;

            for (int i = 0; i < numSegments; i++)
            {
                var primitive = PrimitiveHelper.CreatePrimitive(shapeType, false);

                Transform segParent = new GameObject($"Segment {i}").transform;
                segParent.SetParent(transform);
                segParent.localPosition = Vector3.zero;

                primitive.transform.SetParent(segParent);

                primitive.GetComponent <MeshRenderer>().material = segmentMaterial;

                primitive.transform.forward =
                    segParent.rotation * PointerUtils.GetPrimitiveForward(shapeType);

                primitive.transform.localScale = PointerUtils.GetPrimitiveScale(shapeType);

                segments.Add(segParent.gameObject);
            }
        }