private void DrawColliderInspector() { SerializedProperty colliderProp = serializedObject.FindProperty("ShapeColliderIndex"); EditorGUILayout.LabelField("Collider", EditorStyles.boldLabel); Rect rect = EditorGUILayout.GetControlRect(false, 2); rect.x = 0.0f; rect.y -= 1.0f; rect.width = Screen.width; EditorGUI.DrawRect(rect, seperatorColor); EditorGUILayout.PropertyField(colliderProp, new GUIContent("")); bool allowMultiobjectEditing = false; for (int i = 0; i < targets.Length && !allowMultiobjectEditing; i++) { if (((QuickPolygon)targets[i]).ShapeColliderIndex != ColliderType.None) { allowMultiobjectEditing = true; } } if (allowMultiobjectEditing) { if (GUILayout.Button("Remove Collider")) { Undo.RecordObjects(targets, "Remove Collider"); for (int i = 0; i < targets.Length; i++) { ColliderManager.RemoveColliders((QuickPolygon)targets[i]); } } } }
public void RecalculateMesh() { if (Shape == null) { return; } Shape.facingDirection = 0; LastData = Shape.GetData(); ProportionsModifier.ModifyData(LastData, GetComponent <RectTransform>()); if (Fill != null) { Fill.ModifyData(LastData, Material); } else { EmptyFill.ModifyData(LastData, Material); } if (Border != null) { ((StandardBorder)Border).KeepGeometry = ShapeFillIndex != FillType.None; Border.ModifyData(LastData, Material); } // Don't show the fill mesh if the fill is empty. if (ShapeFillIndex == FillType.None && Border == null) { LastData.Triangles = new int[0]; } if (!IsUI) { PivotModifier.ModifyData(LastData, transform); } UVModifier.ModifyData(LastData); FacingModifier.ModifyData(LastData); SortingLayerModifier.ModifyData(LastData, GetComponent <MeshRenderer>()); Mesh mesh = GetComponent <MeshFilter>().sharedMesh; mesh.Clear(); mesh.vertices = LastData.Vertices; mesh.triangles = LastData.Triangles; mesh.colors = LastData.Colors; mesh.uv = LastData.UV; mesh.name = Shape.Name; mesh.RecalculateNormals(); if (ShapeColliderIndex != ColliderType.None && (Fill == null || Fill is EmptyFill) && Border == null) { Debug.LogWarning(Warnings.COLLIDER_POLYGON_FILL_AND_BORDER_NOT_EXIST, this); ShapeColliderIndex = ColliderType.None; } ColliderManager.ReloadCollider(this, ShapeColliderIndex, LastData, ((StandardBorder)Border)); Lighting = lighting; if (GetComponent <RectTransform>() != null) { RectTransform tfm = GetComponent <RectTransform>(); Vector3 size = new Vector3(ProportionsModifier.width, ProportionsModifier.height); tfm.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x * 90.6f); tfm.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y * 90.6f); } }