Пример #1
0
        private void GenerateMesh()
        {
            UOUtility.DestroyChildren(generated);

            int   i             = 0;
            float textureOffset = 0.0f;

            foreach (CubicBezierCurve curve in spline.GetCurves())
            {
                GameObject go = UOUtility.Create("segment " + i++,
                                                 generated,
                                                 typeof(MeshFilter),
                                                 typeof(MeshRenderer),
                                                 typeof(ExtrusionSegment),
                                                 typeof(MeshCollider));
                go.isStatic = true; // TODO Changed
                go.GetComponent <MeshRenderer>().material = material;
                ExtrusionSegment mb = go.GetComponent <ExtrusionSegment>();
                mb.ShapeVertices = shapeVertices;
                mb.TextureScale  = textureScale;
                mb.TextureOffset = textureOffset;
                mb.SampleSpacing = sampleSpacing;
                mb.SetInterval(curve);

                textureOffset += curve.Length;
            }
        }
Пример #2
0
        protected void GenerateMesh()
        {
            UOUtility.DestroyChildren(generated);

            int   i             = 0;
            float textureOffset = 0.0f;

            foreach (CubicBezierCurve curve in spline.GetCurves())
            {
                GameObject go = UOUtility.Create("segment " + i++,
                                                 generated,
                                                 typeof(MeshFilter),
                                                 typeof(MeshRenderer),
                                                 typeof(ExtrusionSegment),
                                                 typeof(MeshCollider));
                MeshRenderer goRenderer = go.GetComponent <MeshRenderer>();
                goRenderer.material = material;
                ExtrusionSegment seg = go.GetComponent <ExtrusionSegment>();
                seg.ShapeVertices = shapeVertices;
                seg.TextureScale  = textureScale;
                seg.TextureOffset = textureOffset;
                seg.SampleSpacing = sampleSpacing;
                seg.SetInterval(curve);
                goRenderer.enabled = visible;
                if (go.TryGetComponent(out MeshCollider meshCollider))
                {
                    meshCollider.enabled = collisionEnabled;
                }
                int layerNum = LayerMask.NameToLayer(layer);
                if (layerNum > -1)
                {
                    go.gameObject.layer = layerNum;
                }

                textureOffset += curve.Length;
            }
        }