Exemple #1
0
        public void EnsureShapeMeshGenerationDoesNotOverflowAllocation()
        {
            var shapePath = new Vector3[4] {
                new Vector3(-76.04548f, 7.522535f, 0f), new Vector3(-66.52518f, 18.88778f, 0f), new Vector3(-66.35441f, 24.34475f, 0), new Vector3(-75.15407f, 33.0358f, 0)
            };
            var light = m_TestObjectCached.AddComponent <Light2D>();

            light.lightType = Light2D.LightType.Freeform;
            LightUtility.GenerateShapeMesh(light, shapePath, 180.0f);

            Assert.AreEqual(true, light.hasCachedMesh);
        }
        protected override void SetShape(ScriptablePath shapeEditor, SerializedObject serializedObject)
        {
            serializedObject.Update();

            var pointsProperty = serializedObject.FindProperty(k_ShapePath);

            pointsProperty.arraySize = shapeEditor.pointCount;

            for (var i = 0; i < shapeEditor.pointCount; ++i)
            {
                pointsProperty.GetArrayElementAtIndex(i).vector3Value = shapeEditor.GetPoint(i).position;
            }

            // This is untracked right now...
            serializedObject.ApplyModifiedProperties();

            ShadowCaster2D shadowCaster = target as ShadowCaster2D;

            if (shadowCaster != null)
            {
                int hash = LightUtility.GetShapePathHash(shadowCaster.shapePath);
                shadowCaster.shapePathHash = hash;
            }
        }